1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639 |
- <?php
- // SSB - Simple Social Board
- // (C) Chris Dorman, 2012 - 2020
- // License: CC-BY-NC-SA version 3.0
- // http://github.com/Pentium44/SSB
- //// For development debug.
- //error_reporting(E_ALL);
- //ini_set('display_errors', 1);
- session_start();
- include "config.php";
- include "functions.php";
- include "bbcode.php";
- $loginCheck = checkLogin();
- // check if flatfile database location is populated
- if(!file_exists("ssb_db"))
- {
- mkdir("ssb_db", 0777);
- }
- if(!file_exists("ssb_db/users"))
- {
- mkdir("ssb_db/users", 0777);
- }
- if(!file_exists("ssb_db/posts"))
- {
- mkdir("ssb_db/posts", 0777);
- }
- if(!file_exists("ssb_db/uploads"))
- {
- mkdir("ssb_db/uploads", 0777);
- }
- if(!file_exists("ssb_db/friends"))
- {
- mkdir("ssb_db/friends", 0777);
- }
- $username = $_SESSION['ssb-user'];
- //$_SESSION['ssb-topic'] = $ssbtopic;
- ?>
- <!DOCTYPE html>
- <html lang="en-us">
- <head>
- <title><?php echo htmlentities(stripslashes($ssbtitle)); ?></title>
- <?php
- if($_GET['do']!="post" && $_GET['do']!="reply" && $_GET['do']!="react" && $_GET['do']!="avatarupload" && $_GET['do']!="delpost") {
- echo '<meta http-equiv="content-type" content="text/html; charset=utf-8">';
- }
- ?>
- <meta name="viewport" content="width=device-width, initial-scale=.55, shrink-to-fit=yes"><meta name="description" content="<?php echo htmlentities($ssbtitle) . " - " . $desc; ?>">
- <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
- <link rel="stylesheet" type="text/css" href="style.css">
- </head>
- <body <?php if($_GET['do']=="privmsg") { echo "onload=\"UpdateTimer();\""; } ?>>
- <div class="maincontain">
- <div id="navbar" style="width: 99%;">
- <?php if(isset($_SESSION['ssb-user']) && isset($_SESSION['ssb-pass'])) { ?>
- <div class="dropdown">
- <button class="dropbtn"><i class="fa-solid fa-user-group"></i> Account & Posting</button>
- <div class="dropdown-content">
- <a href="?forms=post" title="Post on your feed!">Make a Post</a>
- <a href="index.php">User Feed</a>
- <a href="?do=friends">Friends</a>
- </div>
- </div>
- <div class="dropdown" style="float: right;">
- <button class="dropbtn"><i class="fa-solid fa-gears"></i> Settings Menu</button>
- <div class="dropdown-content" style="right: 0;">
- <a href="?userfeed=<?php echo $username; ?>" title="Your profile!">Your Profile</a>
- <a href="?do=userctrl">User Panel</a>
- <a href="?do=about">About</a>
- <a href="?do=logout">Logout</a>
- </div>
- </div>
- <!--<a style="width:50px;" href="?do=users" title="Public users!"></a>-->
- <?php } else { ?>
- <a href="?forms=login"><i class="fa-solid fa-left-from-bracket"></i></a>
- <a href="?do=about"><i class="fa-solid fa-circle-info"></i></a><br />
- <?php } ?>
- </div>
- <!--<div class="title"><?php echo $ssbtitle; ?></div>-->
- <?php
- if(($loginCheck == true) && $_GET['do']!="avatarlocation" && $_GET['do']!="reply" && $_GET['do']!="post" && $_GET['do']!="react" && $_GET['do']!="delpost") {
- // PM notifications
- $notifications = "ssb_db/friends/" . $username . ".notifications";
- $handle = fopen($notifications, "r");
- echo "<table class='notifications'><tr><td>Notifications: <a class='button' onclick=\"userClrNotifications();\">Clear</a></td></tr>";
- if ($handle) {
- while (($line = fgets($handle)) !== false) {
- echo "<tr><td><i class='fa fa-exclamation' aria-hidden='true'></i> " . $line . "</td></tr>";
- }
- fclose($handle);
- } else {
- echo "<tr><td>No notifications</td></tr>";
- }
- echo "</table></td><td class='contain'>";
- } else {
- echo "</td><td class='contain'>";
- }
- ?>
- <?php
- if(isset($_GET['forms']))
- {
- $forms = $_GET['forms'];
- $id = $_GET['pid'];
- if($forms=="register") {
- registerForm();
- }
- else if($forms=="login") {
- loginForm();
- }
- else if($forms=="friendreq") {
- if($loginCheck == true) {
- friendReqForm();
- } else {
- loginForm();
- }
- }
- else if($forms=="changepass") {
- if($loginCheck == true) {
- changePassForm();
- } else {
- loginForm();
- }
- }
- else if($forms=="deleteacct") {
- if($loginCheck == true) {
- deleteAcctForm();
- } else {
- loginForm();
- }
- }
- else if($forms=="avatarupload") {
- if($loginCheck == true) {
- uploadAvatarForm();
- } else {
- loginForm();
- }
- }
- else if($forms=="post") {
- if($loginCheck == true) {
- postForm();
- } else {
- loginForm();
- }
- }
- else if($forms=="clean") {
- if($loginCheck == true) {
- cleanForm();
- } else {
- loginForm();
- }
- }
- else {
- echo "ERROR: Unknown form-name<br>";
- }
- }
- 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 if($notify=="7") { echo "Error: Current password incorrect!"; }
- else if($notify=="8") { echo "Success! Current password changed!"; }
- 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 ($loginCheck == true) {
- $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 "<table><tr><td>";
- echo "<div class='avatar' style=\"background-image: url('index.php?do=avatarlocation&user=" . $userid . "');\" title='User Avatar'></div><br />";
- // DONE
- echo "</td><td>";
- echo "<h3>User information</h3>";
- echo "Username: " . $userid . "@" . $domain . "<br />";
- echo "Full name: " . $user_fullname . "<br />";
- echo "<h3>User posts</h3>";
- echo "</td></tr></table>";
- }
- }
- // Check if viewing your own profile
- if($userid == $username)
- {
- echo "<table><tr><td>";
- // Get user avatar if set
- echo "<div class='avatar' style=\"background-image: url('index.php?do=avatarlocation&user=" . $userid . "');\" title='User Avatar'></div><br />";
- // DONE
- echo "</td><td>";
- echo "<h3>User information</h3>";
- echo "Username: " . $userid . "@" . $domain . "<br />";
- echo "Full name: " . $user_fullname . "<br />";
- echo "<h3>User posts</h3>";
- echo "</td></tr></table>";
- }
- // Lets generate the users feed now.
- foreach(array_reverse(glob("ssb_db/posts/post_" . $userid . "_" . "*.php")) as $postfile) {
- //echo $postfile;
- unset($shared); // Keep clean variables
- include $postfile;
- for($x = 1; $x <= $friendcount; $x++)
- {
- if($postowner == ${"friend" . $x}) {
- echo "<div class='post'><table><tr><td><div class='avatar_small' style=\"background-image: url('index.php?do=avatarlocation&user=$postowner');\" title='User Avatar'></div></td><td><h3>$postowner<span class='date'>$postdate ";
- if(file_exists("ssb_db/posts/$postid.reactcount")) {
- $reacts = file_get_contents("ssb_db/posts/$postid.reactcount");
- echo "<div class='reacts'><i class='fa fa-heart' style='color: red;'></i> $reacts <div class='react-list'>";
- // 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 "<b>$reactor</b>";
- }
- fclose($reactlist);
- }
- echo "</div></div>";
- }
-
- if(isset($shared) && $shared == "1")
- {
- echo "<br />Originally posted by $origowner";
- }
-
- echo "</span></h3></td></tr></table>";
- echo "" . bbcode_format($postcontent) . "";
-
- // Footer
- echo "<div class='post-footer'>";
- echo "<a style='padding-top: 6px;' onclick=\"userReact('" . $postowner . "','" . $postid . "');\" class='button'><i class='fa fa-heart'></i> React</a>";
- echo "<a style='padding-top: 6px;' href='index.php?view=$postid&user=$postowner' class='button'><i class='fa fa-comment'></i> Comment</a>";
- echo "<a style='padding-top: 6px;' href='index.php?do=share&pid=$postid&user=$postowner' class='button'><i class='fa fa-share'></i> Share</a>";
- echo "<br />"; // line break
- if(file_exists("ssb_db/posts/reply_" . $postowner . "_" . $postid . ".count")) {
- $postcount = file_get_contents("ssb_db/posts/reply_" . $postowner . "_" . $postid . ".count");
- // If there's a reply, show them.
- if($postcount == 0) {
- echo "no replies";
- } else if($postcount == 1) {
- echo "$postcount reply";
- } else if ($postcount > 0) {
- echo "$postcount replies";
- }
- }
-
- echo " • ";
-
- // Show reaction count in footer as well.
- if(file_exists("ssb_db/posts/" . $postid . ".reactcount")) {
- $reactcount = file_get_contents("ssb_db/posts/" . $postid . ".reactcount");
- if($reactcount == 1) {
- echo "$reactcount reaction";
- } else if ($reactcount > 0) {
- echo "$reactcount reactions";
- }
- } else {
- echo "no reactions";
- }
-
- echo "</div></div><br />\n";
- }
- }
- if($postowner == $username)
- {
- echo "<div class='post'><table><tr><td><div class='avatar_small' style=\"background-image: url('index.php?do=avatarlocation&user=$postowner');\" title='User Avatar'></div></td><td><h3>$postowner<span class='date'>$postdate ";
- if(file_exists("ssb_db/posts/$postid.reactcount")) {
- $reacts = file_get_contents("ssb_db/posts/$postid.reactcount");
- echo "<div class='reacts'><i class='fa fa-heart' style='color: red;'></i> $reacts <div class='react-list'>";
- // 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 "<b>$reactor</b>";
- }
- fclose($reactlist);
- }
- echo "</div></div>";
- }
-
- if(isset($shared) && $shared == "1")
- {
- echo "<br />Originally posted by $origowner";
- }
-
- echo "</span></h3></td></tr></table>";
- echo "" . bbcode_format($postcontent) . "";
- // Footer
- echo "<div class='post-footer'>";
- echo "<a style='padding-top: 6px;' onclick=\"userReact('" . $postowner . "','" . $postid . "');\" class='button'><i class='fa fa-heart'></i> React</a>";
- echo "<a style='padding-top: 6px;' href='index.php?view=$postid&user=$postowner' class='button'><i class='fa fa-comment'></i> Comment</a>";
- echo "<a style='padding-top: 6px;' href='index.php?do=delpost&user=$username&pid=$postid' class='button'><i class='fa fa-trash-can'></i> Delete</a>";
- echo "<br />"; // line break
- if(file_exists("ssb_db/posts/reply_" . $postowner . "_" . $postid . ".count")) {
- $postcount = file_get_contents("ssb_db/posts/reply_" . $postowner . "_" . $postid . ".count");
- // If there's a reply, show them.
- if($postcount == 0) {
- echo "no replies";
- } else if($postcount == 1) {
- echo "$postcount reply";
- } else if ($postcount > 0) {
- echo "$postcount replies";
- }
- }
-
- echo " • ";
-
- // Show reaction count in footer as well.
- if(file_exists("ssb_db/posts/" . $postid . ".reactcount")) {
- $reactcount = file_get_contents("ssb_db/posts/" . $postid . ".reactcount");
- if($reactcount == 1) {
- echo "$reactcount reaction";
- } else if ($reactcount > 0) {
- echo "$reactcount reactions";
- }
- } else {
- echo "no reactions";
- }
-
- echo "</div></div><br />\n";
- }
- }
- echo "<!-- Gen done...-->";
- }
- }
- else
- {
- echo "<h3>User information</h3>";
- echo "<table><tr><td>";
- echo "<div class='avatar' style=\"background-image: url('index.php?do=avatarlocation&user=$userid');\" title='User Avatar'></div>";
- // DONE
-
- echo "</td><td>";
- // 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 "<a class='button' href='index.php?do=sendfr&user=$userid'>Send friend request</a><br /><br />";
- }
-
- echo "Username: " . $userid . "@" . $domain . "<br />";
- echo "Full name: " . $user_fullname;
- echo "</td></tr></table>";
- foreach(array_reverse(glob("ssb_db/posts/post_" . $userid . "_" . "*.php")) as $postfile) {
- include $postfile;
- unset($shared);
- echo "<div class='post'><table><tr><td><div class='avatar_small' style=\"background-image: url('index.php?do=avatarlocation&user=$postowner');\" title='User Avatar'></div></td><td><h3>$postowner<span class='date'>$postdate ";
- if(file_exists("ssb_db/posts/$postid.reactcount")) {
- $reacts = file_get_contents("ssb_db/posts/$postid.reactcount");
- echo "<div class='reacts'><i class='fa fa-heart' style='color: red;'></i> $reacts <div class='react-list'>";
- // 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 "<b>$reactor</b>";
- }
- fclose($reactlist);
- }
- echo "</div></div>";
- }
-
- if(isset($shared) && $shared == "1")
- {
- echo "<br />Originally posted by $origowner";
- }
-
- echo "</span></h3></td></tr></table>";
- echo "" . bbcode_format($postcontent) . "";
- // Footer
- echo "<div class='post-footer'>";
- echo "<a style='padding-top: 6px;' onclick=\"userReact('" . $postowner . "','" . $postid . "');\" class='button'><i class='fa fa-heart'></i> React</a>";
- echo "<a style='padding-top: 6px;' href='index.php?view=$postid&user=$postowner' class='button'><i class='fa fa-comment'></i> Comment</a>";
- echo "<a style='padding-top: 6px;' href='index.php?do=share&pid=$postid&user=$postowner' class='button'><i class='fa fa-share'></i> Share</a>";
- echo "<br />"; // line break
- if(file_exists("ssb_db/posts/reply_" . $postowner . "_" . $postid . ".count")) {
- $postcount = file_get_contents("ssb_db/posts/reply_" . $postowner . "_" . $postid . ".count");
- // If there's a reply, show them.
- if($postcount == 0) {
- echo "no replies";
- } else if($postcount == 1) {
- echo "$postcount reply";
- } else if ($postcount > 0) {
- echo "$postcount replies";
- }
- }
-
- echo " • ";
-
- // Show reaction count in footer as well.
- if(file_exists("ssb_db/posts/" . $postid . ".reactcount")) {
- $reactcount = file_get_contents("ssb_db/posts/" . $postid . ".reactcount");
- if($reactcount == 1) {
- echo "$reactcount reaction";
- } else if ($reactcount > 0) {
- echo "$reactcount reactions";
- }
- } else {
- echo "no reactions";
- }
-
- echo "</div></div><br />\n";
- }
-
- echo "<!-- Gen done...-->";
- }
- }
- 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 "<div class='post'><table><tr><td><div class='avatar_small' style=\"background-image: url('index.php?do=avatarlocation&user=$postowner');\" title='User Avatar'></div></td><td><h3>$postowner<span class='date'>$postdate ";
- if(file_exists("ssb_db/posts/$postid.reactcount")) {
- $reacts = file_get_contents("ssb_db/posts/$postid.reactcount");
- echo "<div class='reacts'><i class='fa fa-heart' style='color: red;'></i> $reacts <div class='react-list'>";
- // 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 "<b>$reactor</b>";
- }
- fclose($reactlist);
- }
- echo "</div></div>";
- }
- if(isset($shared) && $shared == "1")
- {
- echo "<br />Originally posted by $origowner";
- }
- echo "</span></h3></td></tr></table>";
- echo "" . bbcode_format($postcontent) . "";
- // Footer
-
- echo "<a style='padding-top: 6px;' onclick=\"userReact('" . $postowner . "','" . $postid . "');\" class='button'><i class='fa fa-heart'></i> React</a>";
- echo "<a style='padding-top: 6px;' href='index.php?do=share&pid=$postid&user=$postowner' class='button'><i class='fa fa-share'></i> Share</a>";
-
- echo "</div><br />\n";
- for($x = 1; $x <= $postc; $x++) {
- $reply_content = ${"reply" . $x};
- $reply_user = ${"reply" . $x . "_user"};
- $reply_date = ${"reply" . $x . "_date"};
-
- echo "<div class='reply'>";
- echo "<table><tr><td><div class='avatar_small' style='background-image: url(\"index.php?do=avatarlocation&user=$reply_user\");' title='User Avatar'></div></td><td><h4>$reply_user <a onclick=\"userTag('$reply_user');\"><i class='fa fa-tag'></i></a> <span class=\"date\">$reply_date</span></h4></td></tr></table>";
- echo "<div class='reply_content'>" . bbcode_format($reply_content) . "</div>";
- echo "</div>\n";
- }
- echo "<br />";
- if ($loginCheck != true) {
- 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...<br />";
- }
- }
- }
- else if(isset($_GET['do']))
- {
- $do = $_GET['do'];
- if($do=="post")
- {
- if ($loginCheck != true) { 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<count($_FILES["file"]["name"]); $i++)
- {
- $allowedExts = array("gif", "jpeg", "jpg", "png", "bmp", "ico", "GIF", "JPEG", "JPG", "PNG", "BMP", "ICO", "mp4", "MP4");
- $temp = explode(".", $_FILES["file"]["name"][$i]);
- $extension = end($temp);
- if ((($_FILES["file"]["type"][$i] == "image/gif")
- || ($_FILES["file"]["type"][$i] == "image/x-gif")
- || ($_FILES["file"]["type"][$i] == "image/jpeg")
- || ($_FILES["file"]["type"][$i] == "image/x-jpeg")
- || ($_FILES["file"]["type"][$i] == "image/x-jpg")
- || ($_FILES["file"]["type"][$i] == "image/jpg")
- || ($_FILES["file"]["type"][$i] == "image/pjpeg")
- || ($_FILES["file"]["type"][$i] == "image/x-png")
- || ($_FILES["file"]["type"][$i] == "image/bmp")
- || ($_FILES["file"]["type"][$i] == "image/x-icon")
- || ($_FILES["file"]["type"][$i] == "application/octet-stream")
- || ($_FILES["file"]["type"][$i] == "video/mp4")
- // || ($_FILES["file"]["type"][$i] == "video/ogg")
- // || ($_FILES["file"]["type"][$i] == "video/webm")
- // || ($_FILES["file"]["type"][$i] == "video/x-flv")
- // || ($_FILES["file"]["type"][$i] == "video/mp4v-es")
- || ($_FILES["file"]["type"][$i] == "image/png")
- || ($_FILES["file"]["type"][$i] == ""))
- && ($_FILES["file"]["size"][$i] < $user_max_upload)
- && in_array($extension, $allowedExts))
- {
-
- if ($_FILES["file"]["error"][$i] > 0)
- {
- echo $_FILES["file"]["name"][$i] . " - Return Code: " . $_FILES["file"]["error"][$i] . "<br />";
- }
- else
- {
- if(file_exists("ssb_db/uploads/" . $_FILES["file"]["name"][$i]))
- {
- echo "Error: " . $_FILES["file"]["name"][$i] . " exists.<br />";
- }
- 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...<br />";
- //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", "<b>$username</b> <a href='index.php?view=$date&user=$username'>tagged you in a post</a>\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 = "<br />";
- $post_string = "<?php\n\$postowner = \"" . $username . "\";\$postid=\"" . $date . "\";\$postdate=\"" . $titledate . "\";\$postcontent = \"" . $body . "<br />";
-
- $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, "<div class='attachment'>" . $uploaded_name[$fileCount] . "<video width='560' height='315' controls><source src='ssb_db/uploads/$upload' type='video/mp4'>HTML5 video not supported :(</video></div>");
- }
- else
- {
- array_push($attachments, "<div class='attachment'><a href='ssb_db/uploads/" . $upload . "'><img src='ssb_db/uploads/" . $upload . "'></a></div>");
- }
- }
-
- $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, <a href=\"?view=$date&user=$username\">Click Here</a><br />";
- header("Location: index.php?view=$date&user=$username");
- }
- else
- {
- echo "ERROR: Missing post data! Select an image to upload or let us know whats up!<br />";
- }
- }
- }
-
- if($do=="avatarupload")
- {
- if(isset($_FILES["file"]["name"]) && ($loginCheck == true)) {
- $date = date("YmdHis"); // timestamp in year, month, date, hour, minute, and second.
- for($i=0; $i<count($_FILES["file"]["name"]); $i++)
- {
- $allowedExts = array("gif", "jpeg", "jpg", "png", "bmp", "ico", "png");
- $temp = explode(".", $_FILES["file"]["name"][$i]);
- $extension = end($temp);
- if ((($_FILES["file"]["type"][$i] == "image/gif")
- || ($_FILES["file"]["type"][$i] == "image/x-gif")
- || ($_FILES["file"]["type"][$i] == "image/jpeg")
- || ($_FILES["file"]["type"][$i] == "image/x-jpeg")
- || ($_FILES["file"]["type"][$i] == "image/x-jpg")
- || ($_FILES["file"]["type"][$i] == "image/jpg")
- || ($_FILES["file"]["type"][$i] == "image/pjpeg")
- || ($_FILES["file"]["type"][$i] == "image/x-png")
- || ($_FILES["file"]["type"][$i] == "image/bmp")
- || ($_FILES["file"]["type"][$i] == "image/x-icon")
- || ($_FILES["file"]["type"][$i] == "image/png")
- || ($_FILES["file"]["type"][$i] == ""))
- && ($_FILES["file"]["size"][$i] < $user_max_upload)
- && in_array($extension, $allowedExts))
- {
- if ($_FILES["file"]["error"][$i] > 0)
- {
- echo $_FILES["file"]["name"][$i] . " - Return Code: " . $_FILES["file"]["error"][$i] . "<br>";
- }
- else
- {
- if(file_exists("ssb_db/uploads/" . $_FILES["file"]["name"][$i]))
- {
- echo "Error: " . $_FILES["file"]["name"][$i] . " exists.<br>";
- }
- 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 . "<?php \$user_avatar = \"" . $username . "_" . $date . "." . $extension . "\"; ?>\n");
- echo "Avatar uploaded and set! <a href='index.php'>Redirecting</a> 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=="reply")
- {
- if ($loginCheck != true) { 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", "<b>$username</b> <a href='index.php?view=$pid&user=$postowner'>tagged you in a comment</a>\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 = "<?php \n\$reply" . $reply_count . " = \"" . $body . "\";\$reply" . $reply_count . "_user = \"" . $username . "\"; \$reply" . $reply_count . "_date = \"" . $replydate . "\";\n?>\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", "<b>$username</b> <a href='index.php?view=$pid&user=$postowner'>replied to your post</a>\n" . $owner_notifications);
- }
- echo "If you're seeing this; redirection failed: <a href=\"?view=$pid&user=$postowner\">Click Here</a><br>";
- header("Location:index.php?view=$pid&user=$postowner");
- }
- else
- {
- echo "ERROR: Missing form data<br>";
- }
- }
- }
- }
-
- if($do=="delpost")
- {
- if ($loginCheck != true) { loginForm(); } else {
- 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");
- flush();
- header("refresh: 0;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!"; }
- }
- }
-
- if($do=="share")
- {
- if ($loginCheck != true) { loginForm(); } else {
- 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 = stripslashes($_GET['user']);
- $pid = stripslashes($_GET['pid']);
- $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
- include("ssb_db/friends/" . $username . ".php");
- include("ssb_db/posts/post_" . $postuser . "_" . $pid . ".php");
-
- if($accttype == "public") {
- $post_file = "ssb_db/posts/post_" . $username . "_" . $date . ".php";
- $post_attachments = "<br />";
- $post_string = "<?php\n\$postowner = \"" . $username . "\";\$postid=\"" . $date . "\";\$postdate=\"" . $titledate . "\";\$shared = \"1\";\$origowner = \"" . $postowner . "\";\$postcontent = \"" . $postcontent;
- $post_string_end = "\";\n?>\n";
- $notification = file_get_contents("ssb_db/friends/" . $postuser . ".notifications");
- file_put_contents("ssb_db/friends/" . $postuser . ".notifications", "<b>$username</b> <a href='index.php?view=$date&user=$username'>shared your post</a>\n" . $notification);
- 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");
- flush();
- header("refresh: 0;url=index.php");
- exit;
- } else {
- $friendcount = file_get_contents("ssb_db/friends/" . $username . ".count");
- for($x = 1; $x <= $friendcount; $x++)
- {
- if($postowner == ${"friend" . $x}) {
- $foundfriend = 1;
- $post_file = "ssb_db/posts/post_" . $username . "_" . $date . ".php";
- $post_attachments = "<br />";
- $post_string = "<?php\n\$postowner = \"" . $username . "\";\$postid=\"" . $date . "\";\$postdate=\"" . $titledate . "\";\$shared = \"1\";\$origowner = \"" . $postowner . "\";\$postcontent = \"" . $postcontent;
- $post_string_end = "\";\n?>\n";
- $notification = file_get_contents("ssb_db/friends/" . $postuser . ".notifications");
- file_put_contents("ssb_db/friends/" . $postuser . ".notifications", "<b>$username</b> <a href='index.php?view=$date&user=$username'>shared your post</a>\n" . $notification);
- 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");
- flush();
- header("refresh: 0;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!"; }
- }
- }
-
- if($do=="react")
- {
- if ($loginCheck != true) { loginForm(); } else {
- 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... <a href='index.php?view=$pid&user=$postuser'>redirecting</a>";
- header("refresh: 3;url=index.php?view=$pid&user=$postuser");
- exit;
- }
- }
- fclose($handle);
- } else {
- echo "<!-- Haven't reacted, continuing -->";
- }
-
- 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", "<b>$username</b> loved your <a href='index.php?view=$pid&user=$postuser'>post</a>\n" . $owner_notifications);
- }
-
- echo "Reacted! <a href='index.php'>Redirecting</a> in 1 second...";
- header("Location:index.php");
- exit;
- } else { echo "ERROR: post doesn't exist..."; }
- } else { echo "ERROR: USER and PID variables not set!"; }
- }
- }
-
- if($do=="clrnote")
- {
- if ($loginCheck != true) { loginForm(); } else {
- unlink("ssb_db/friends/" . $username . ".notifications");
- header("Location: index.php");
- exit;
- }
- }
-
- if($do=="clrpending")
- {
- if ($loginCheck != true) { loginForm(); } else {
- unlink("ssb_db/friends/" . $username . ".pending");
- header("Location: index.php?do=friends");
- exit;
- }
- }
- // 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<br>";
- }
- else
- {
- echo "ERROR: Wrong Password<br>";
- }
- }*/
- // grab session values and send friend request functions.
- if($do=="sendfr") {
- if ($loginCheck != true) { 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 . " <a href='?do=friends'>redirecting</a> 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 ($loginCheck != true) { 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'])) . " <a href='?do=friends'>redirecting</a> in 3 seconds";
- header("refresh: 3;url=?do=friends");
- } else {
- echo "Error: users not set in GET & SESSION value...";
- }
- }
- }
- if($do=="userctrl")
- {
- if ($loginCheck != true) { loginForm(); } else {
- // Beginning of user control panel
- echo "<h3>User control panel</h3>";
- echo "<a class='button' href='?forms=changepass'>Change password</a><br />";
- echo "<a class='button' href='?forms=avatarupload'>Upload avatar</a><br />";
- }
- }
- if($do=="changepass")
- {
- if ($loginCheck != true) { 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 = "<?php \$user_password = \"" . sha1(md5($newPassInput)) . "\"; ?>\n";
- file_put_contents("ssb_db/users/" . $username . ".php", $oldcontent . $passString);
- echo "Password changed, <a href='index.php'>redirecting</a> 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=="privmsg")
- {
- if ($loginCheck != true) { 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}) {
- ?>
- <script language="javascript" type="text/javascript">
- <!--
- var httpObject = null;
- var link = "";
- var timerID = 0;
- var friendNick = "<?php echo $friendNick; ?>";
- var nickName = "<?php echo $_SESSION['ssb-user']; ?>";
- var userColor = "<?php echo $_SESSION['ssb-color'];; ?>";
- // Change the value of the outputText field
- function setHtml() {
- if(ajaxVar.readyState == 4){
- var response = ajaxVar.responseText;
- var msgBox = document.getElementById("msgs");
- msgBox.innerHTML += response;
- msgBox.scrollTop = msgBox.scrollHeight;
- }
- }
- // Change the value of the outputText field
- function setAll() {
- if(ajaxVar.readyState == 4){
- var response = ajaxVar.responseText;
- var msgBox = document.getElementById("msgs");
- msgBox.innerHTML = response;
- msgBox.scrollTop = msgBox.scrollHeight;
- }
- }
- // Implement business logic
- function serverWrite() {
- ajaxVar = getHTTPObject();
- if (ajaxVar != null) {
- link = "chatserver.php?nick="+nickName+"&friend="+friendNick+"&msg="+document.getElementById('msg').value;
- ajaxVar.open("GET", link , true);
- ajaxVar.onreadystatechange = setHtml;
- ajaxVar.send(null);
- }
- }
-
- function getInput() {
- // Send the server function the input
- var userInput = document.getElementById('msg');
- serverWrite(userInput.value);
- // Clean out the input values
- var msgBar = document.getElementById("msg");
- msgBar.value = "";
- msgBar.focus();
- }
- // Implement business logic
- function serverReload() {
- ajaxVar = getHTTPObject();
- //var randomnumber=Math.floor(Math.random()*10000);
- if (ajaxVar != null) {
- link = "chatserver.php?get=<?php echo $friendNick; ?>";
- ajaxVar.open("GET", link , true);
- ajaxVar.onreadystatechange = setAll;
- ajaxVar.send(null);
- }
- }
-
- function UpdateTimer() {
- serverReload();
- setTimeout(UpdateTimer, 1000);
- }
-
- function keypressed(e) {
- if(e.keyCode=='13'){
- getInput();
- }
- }
- //-->
- </script>
- <div class="replycontain">
- <?php
-
- // Header
- include "ssb_db/users/" . $friendNick . ".php";
- echo "<h3><a href='?userfeed=" . $friendNick . "'>" . $friendNick . ": " . $user_fullname . "</a></h3>";
-
- ?>
- <div id="msgs">
- <?php
- echo "<div class=\"msgbox\">";
- echo "</div>";
- ?>
- </div>
- <div id="msgbox" onkeyup="keypressed(event);">
- <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('img');">Image</button>
- <button onclick="javascript:wrapBBCode('url');">URL</button><br />
- <textarea style="width: 98%;" name="msg" id="msg"></textarea>
- <button style="width: 50px;" onclick="getInput();">Send</button>
- </div>
- </div>
- <?php
- } // Check friend end
- } // Check loop end
- } // GET friend set end
- } // session check end
- } // function end
-
- if($do=="msghist")
- {
- if ($loginCheck != true) { 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}) {
- ?>
- <script language="javascript" type="text/javascript">
- <!--
- var httpObject = null;
- var link = "chatserver.php?get=<?php echo $friendNick; ?>";
- var timerID = 0;
- var friendNick = "<?php echo $friendNick; ?>";
- var nickName = "<?php echo $_SESSION['ssb-user']; ?>";
- var userColor = "<?php echo $_SESSION['ssb-color'];; ?>";
- // Change the value of the outputText field
- function setAll() {
- if(ajaxVar.readyState == 4){
- var response = ajaxVar.responseText;
- var msgBox = document.getElementById("msgs");
- msgBox.innerHTML = response;
- msgBox.scrollTop = msgBox.scrollHeight;
- }
- }
-
- function serverLoad() {
- ajaxVar = getHTTPObject();
- //var randomnumber=Math.floor(Math.random()*10000);
- if (ajaxVar != null) {
- ajaxVar.open("GET", link , true);
- ajaxVar.onreadystatechange = setAll;
- ajaxVar.send(null);
- }
- }
-
- window.addEventListener('load', function () {
- serverLoad();
- });
- //-->
- </script>
- <div class="replycontain">
- <?php
-
- // Header
- include "ssb_db/users/" . $friendNick . ".php";
- echo "<h3><a href='?userfeed=" . $friendNick . "'>" . $friendNick . ": Message history</a></h3>";
-
- ?>
- <div id="msgs">
- <?php
- echo "<div class=\"msgbox\" style=\"overflow-y: scroll;\">";
- echo "</div>";
- ?>
- </div>
- </div>
- <?php
- } // Check friend end
- } // Check loop end
- } // GET friend set end
- } // session check end
- } // function end
- // 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=="about")
- {
- echo "<h2>About</h2>";
- echo "<div class='dllink'><a class='button' href='download/secure-space-v1.1.apk'>Download for Android!</a></div>";
- echo "<p>" . $desc;
- echo "<br /><br />";
- echo "$ssbtitle statistics: ";
- getUserCount();
- echo "; ";
- getPostCount();
- echo "; ";
- getUploadFileCount();
- echo "</p>";
- }
-
- if($do=="users")
- {
- if ($loginCheck != true) { loginForm(); } else {
- echo "<h2>Community</h2>";
- 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 "<table class='friendslist'><tr><td><div class='avatar_small' style=\"background-image: url('index.php?do=avatarlocation&user=$userhandle');\" title='User Avatar'></td>";
- echo "<td><a class='button' href='index.php?userfeed=$userhandle'>$userhandle</a> ~ $user_fullname</td>";
- echo "</td></tr></table>";
- }
- }
- }
- }
- if($do=="friends")
- {
- if ($loginCheck != true) { loginForm(); } else {
- // Friends panel
- echo "<h3>Friends</h3><a href='?do=users' class='button'>Public users</a> <a class='button' href='?forms=friendreq'>Send friend request</a>";
- // Friends list if you have any.
- echo "<br />";
- $friendc = file_get_contents("ssb_db/friends/" . $username . ".count");
- if($friendc == "0")
- {
- echo "<b style='color:red;'>We're sorry... no friends found on your user account...</b>";
- }
- else
- {
- $friendcount = file_get_contents("ssb_db/friends/" . $username . ".count");
- include "ssb_db/friends/" . $username . ".php";
- echo "<table class='friendslist'>";
- for($x = 1; $x <= $friendcount; $x++)
- {
- if(isset(${"friend" . $x}) && file_exists("ssb_db/users/" . ${"friend" . $x} . ".php")) {
- echo "<tr><td><div class='avatar_small' style=\"background-image: url('index.php?do=avatarlocation&user=" . ${"friend" . $x} . "');\" title='User Avatar'></div></td><td><a class='button' href='index.php?userfeed=" . ${"friend" . $x} . "'>" . ${"friend" . $x} . "</a></td><td><a class='button' href='?do=privmsg&friend=" . ${"friend" . $x} . "'>Private message</a> <a href='?do=msghist&friend=" . ${"friend" . $x} . "' class='button'>Message history</a></td></tr>";
- }
- }
- echo "</table>";
- }
- }
- }
- 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", "<?php\n\$accttype = \"" . $acct . "\";\n\$user_password = \"" . sha1(md5($_POST['password'])) . "\";\n \$user_color = \"" . $colors[array_rand($colors)] . "\"; \$user_fullname = \"" . stripslashes(htmlentities($_POST['fullname'])) . "\"; \$user_avatar = \"../../data/defaultprofile.png\"; \n?>");
- 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", "<?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");
- }
- echo "<b>ERROR!</b>: Something weird just happened... please try registering again!!!...";
- //header("Location: index.php");
- }
- }
- else if ($loginCheck != true)
- {
- 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) {
- unset($shared); // make sure its not being carried over after loop.
- $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 "<div class='post'><table><tr><td><div class='avatar_small' style=\"background-image: url('index.php?do=avatarlocation&user=$postowner');\" title='User Avatar'></div></td><td><h3>$postowner<span class='date'>$postdate ";
- if(file_exists("ssb_db/posts/$postid.reactcount")) {
- $reacts = file_get_contents("ssb_db/posts/$postid.reactcount");
- echo "<div class='reacts'><i class='fa fa-heart' style='color: red;'></i> $reacts <div class='react-list'>";
- // 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 "<b>$reactor</b>";
- }
- fclose($reactlist);
- }
- echo "</div></div>";
- }
-
- if(isset($shared) && $shared == "1")
- {
- echo "<br />Originally posted by $origowner";
- }
-
- echo "</span></h3></td></tr></table>";
- echo "" . bbcode_format($postcontent) . "";
- // Footer
- echo "<div class='post-footer'>";
- echo "<a style='padding-top: 6px;' onclick=\"userReact('" . $postowner . "','" . $postid . "');\" class='button'><i class='fa fa-heart'></i> React</a>";
- echo "<a style='padding-top: 6px;' href='index.php?view=$postid&user=$postowner' class='button'><i class='fa fa-comment'></i> Comment</a>";
- echo "<a style='padding-top: 6px;' href='index.php?do=share&pid=$postid&user=$postowner' class='button'><i class='fa fa-share'></i> Share</a>";
- echo "<br />"; // line break
- if(file_exists("ssb_db/posts/reply_" . $postowner . "_" . $postid . ".count")) {
- $pcount = file_get_contents("ssb_db/posts/reply_" . $postowner . "_" . $postid . ".count");
- // If there's a reply, show them.
- if($pcount == 0) {
- echo "no replies";
- } else if($pcount == 1) {
- echo "$pcount reply";
- } else if ($pcount > 0) {
- echo "$pcount replies";
- }
- }
-
- echo " • ";
-
- // Show reaction count in footer as well.
- if(file_exists("ssb_db/posts/" . $postid . ".reactcount")) {
- $reactcount = file_get_contents("ssb_db/posts/" . $postid . ".reactcount");
- if($reactcount == 1) {
- echo "$reactcount reaction";
- } else if ($reactcount > 0) {
- echo "$reactcount reactions";
- }
- } else {
- echo "no reactions";
- }
-
- echo "</div></div><br />\n";
- }
-
- if($poststart > "1" && $postcount > $poststart && $postcount < ($poststart + 15)) {
- echo "<div class='post'><table><tr><td><div class='avatar_small' style=\"background-image: url('index.php?do=avatarlocation&user=$postowner');\" title='User Avatar'></div></td><td><h3>$postowner<span class='date'>$postdate ";
- if(file_exists("ssb_db/posts/$postid.reactcount")) {
- $reacts = file_get_contents("ssb_db/posts/$postid.reactcount");
- echo "<div class='reacts'><i class='fa fa-heart' style='color: red;'></i> $reacts <div class='react-list'>";
- // 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 "<b>$reactor</b>";
- }
- fclose($reactlist);
- }
- echo "</div></div>";
- }
-
- if(isset($shared) && $shared == "1")
- {
- echo "<br />Originally posted by $origowner";
- }
-
- echo "</span></h3></td></tr></table>";
- echo "" . bbcode_format($postcontent) . "";
- // Footer
- echo "<div class='post-footer'>";
- echo "<a style='padding-top: 6px;' onclick=\"userReact('" . $postowner . "','" . $postid . "');\" class='button'><i class='fa fa-heart'></i> React</a>";
- echo "<a style='padding-top: 6px;' href='index.php?view=$postid&user=$postowner' class='button'><i class='fa fa-comment'></i> Comment</a>";
- echo "<a style='padding-top: 6px;' href='index.php?do=share&pid=$postid&user=$postowner' class='button'><i class='fa fa-share'></i> Share</a>";
- echo "<br />"; // line break
- if(file_exists("ssb_db/posts/reply_" . $postowner . "_" . $postid . ".count")) {
- $pcount = file_get_contents("ssb_db/posts/reply_" . $postowner . "_" . $postid . ".count");
- // If there's a reply, show them.
- if($pcount == 0) {
- echo "no replies";
- } else if($pcount == 1) {
- echo "$pcount reply";
- } else if ($pcount > 0) {
- echo "$pcount replies";
- }
- }
-
- echo " • ";
-
- // Show reaction count in footer as well.
- if(file_exists("ssb_db/posts/" . $postid . ".reactcount")) {
- $reactcount = file_get_contents("ssb_db/posts/" . $postid . ".reactcount");
- if($reactcount == 1) {
- echo "$reactcount reaction";
- } else if ($reactcount > 0) {
- echo "$reactcount reactions";
- }
- } else {
- echo "no reactions";
- }
-
- echo "</div></div><br />\n";
- }
- }
- }
- if($postowner == $username)
- {
- // Found a post, post count goes up!
- $postcount++;
-
- if($poststart == "1" && $postcount < ($poststart + 15)) {
- echo "<div class='post'><table><tr><td><div class='avatar_small' style=\"background-image: url('index.php?do=avatarlocation&user=$postowner');\" title='User Avatar'></div></td><td><h3>$postowner<span class='date'>$postdate ";
-
- if(file_exists("ssb_db/posts/$postid.reactcount")) {
- $reacts = file_get_contents("ssb_db/posts/$postid.reactcount");
- echo "<div class='reacts'><i class='fa fa-heart' style='color: red;'></i> $reacts <div class='react-list'>";
- // 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 "<b>$reactor</b>";
- }
- fclose($reactlist);
- }
- echo "</div></div>";
- }
-
- if(isset($shared) && $shared == "1")
- {
- echo "<br />Originally posted by $origowner";
- }
-
- echo "</span></h3></td></tr></table>";
- echo "" . bbcode_format($postcontent) . "";
- // Footer
- echo "<div class='post-footer'>";
- echo "<a style='padding-top: 6px;' onclick=\"userReact('" . $postowner . "','" . $postid . "');\" class='button'><i class='fa fa-heart'></i> React</a>";
- echo "<a style='padding-top: 6px;' href='index.php?view=$postid&user=$postowner' class='button'><i class='fa fa-comment'></i> Comment</a>";
- echo "<a style='padding-top: 6px;' href='index.php?do=delpost&user=$username&pid=$postid' class='button'><i class='fa fa-trash-can'></i> Delete</a>";
- echo "<br />"; // line break
- if(file_exists("ssb_db/posts/reply_" . $postowner . "_" . $postid . ".count")) {
- $pcount = file_get_contents("ssb_db/posts/reply_" . $postowner . "_" . $postid . ".count");
- // If there's a reply, show them.
- if($pcount == 0) {
- echo "no replies";
- } else if($pcount == 1) {
- echo "$pcount reply";
- } else if ($pcount > 0) {
- echo "$pcount replies";
- }
- }
-
- echo " • ";
-
- // Show reaction count in footer as well.
- if(file_exists("ssb_db/posts/" . $postid . ".reactcount")) {
- $reactcount = file_get_contents("ssb_db/posts/" . $postid . ".reactcount");
- if($reactcount == 1) {
- echo "$reactcount reaction";
- } else if ($reactcount > 0) {
- echo "$reactcount reactions";
- }
- } else {
- echo "no reactions";
- }
-
- echo "</div></div><br />\n";
- }
-
- if($poststart > "1" && $postcount > $poststart && $postcount < ($poststart + 15)) {
- echo "<div class='post'><table><tr><td><div class='avatar_small' style=\"background-image: url('index.php?do=avatarlocation&user=$postowner');\" title='User Avatar'></div></td><td><h3>$postowner<span class='date'>$postdate ";
- if(file_exists("ssb_db/posts/$postid.reactcount")) {
- $reacts = file_get_contents("ssb_db/posts/$postid.reactcount");
- echo "<div class='reacts'><i class='fa fa-heart' style='color: red;'></i> $reacts <div class='react-list'>";
- // 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 "<b>$reactor</b>";
- }
- fclose($reactlist);
- }
- echo "</div></div>";
- }
- echo "</span></h3></td></tr></table>";
- echo "" . bbcode_format($postcontent) . "";
- // Footer
- echo "<div class='post-footer'>";
- echo "<a style='padding-top: 6px;' onclick=\"userReact('" . $postowner . "','" . $postid . "');\" class='button'><i class='fa fa-heart'></i> React</a>";
- echo "<a style='padding-top: 6px;' href='index.php?view=$postid&user=$postowner' class='button'><i class='fa fa-comment'></i> Comment</a>";
- echo "<a style='padding-top: 6px;' href='index.php?do=delpost&user=$username&pid=$postid' class='button'><i class='fa fa-trash-can'></i> Delete</a>";
- echo "<br />"; // line break
- if(file_exists("ssb_db/posts/reply_" . $postowner . "_" . $postid . ".count")) {
- $pcount = file_get_contents("ssb_db/posts/reply_" . $postowner . "_" . $postid . ".count");
- // If there's a reply, show them.
- if($pcount == 0) {
- echo "no replies";
- } else if($pcount == 1) {
- echo "$pcount reply";
- } else if ($pcount > 0) {
- echo "$pcount replies";
- }
- }
-
- echo " • ";
-
- // Show reaction count in footer as well.
- if(file_exists("ssb_db/posts/" . $postid . ".reactcount")) {
- $reactcount = file_get_contents("ssb_db/posts/" . $postid . ".reactcount");
- if($reactcount == 1) {
- echo "$reactcount reaction";
- } else if ($reactcount > 0) {
- echo "$reactcount reactions";
- }
- } else {
- echo "no reactions";
- }
-
- echo "</div></div><br />\n";
- }
- }
- }
-
-
- // Page button generation
- echo "<div class='page-controls'>";
-
- if($poststart > "1") {
- $prevpage = $poststart / 15;
- echo "<a href='index.php?page=$prevpage'><i class='fa fa-arrow-left'></i> Prev page</a>";
- }
-
- echo " ";
-
- if($poststart == "1" && $postcount > ($poststart + 15)) {
- echo "<a href='index.php?page=2'>Next page <i class='fa fa-arrow-right'></i></a>";
- }
-
- if($poststart > "1" && $postcount > ($poststart + 15)) {
- $nextpage = ($poststart / 15) + 2;
- echo "<a href='index.php?page=$nextpage'>Next page <i class='fa fa-arrow-right'></i></a>";
- }
-
- echo "</div>";
- }
- ?>
- </td></tr></table>
- <div id="footer">Powered By SSB <?php echo $version; ?></div>
- </div>
- <!-- functions -->
- <script type="text/javascript" src="data/main.js"></script>
- </body>
- </html>
|