2020-11-03 19:39:41 -08:00
< ? php
// SSB - Simple Social Board
// (C) Chris Dorman, 2012 - 2020
// License: CC-BY-NC-SA version 3.0
// http://github.com/Pentium44/SSB
2021-02-13 17:27:03 -08:00
//// For development debug.
2020-11-03 19:39:41 -08:00
//error_reporting(E_ALL);
//ini_set('display_errors', 1);
session_start ();
include " config.php " ;
include " functions.php " ;
include " bbcode.php " ;
2021-02-13 17:27:03 -08:00
$loginCheck = checkLogin ();
2020-11-03 19:39:41 -08:00
// 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>
2021-02-13 17:27:03 -08:00
< ? 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">' ;
}
?>
2020-11-03 19:39:41 -08:00
< 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/4.7.0/css/font-awesome.min.css " >
< link rel = " stylesheet " type = " text/css " href = " style.css " >
</ head >
2021-02-13 17:27:03 -08:00
< body < ? php if ( $_GET [ 'do' ] == " privmsg " ) { echo " onload= \" UpdateTimer(); \" " ; } ?> >
< div class = " title " >< ? php echo $ssbtitle ; ?> </div>
2020-11-03 19:39:41 -08:00
< div class = " maincontain " >
2021-02-13 17:27:03 -08:00
< table id = " containtable " >
< tr >< td id = " navcontainer " >
< div id = " navbar " >
2020-11-03 19:39:41 -08:00
< ? php if ( isset ( $_SESSION [ 'ssb-user' ]) && isset ( $_SESSION [ 'ssb-pass' ])) { ?>
2021-02-13 17:27:03 -08:00
< a style = " width:50px; " href = " ?forms=post " title = " Post on your feed! " > Make a post </ a >< br />
< a style = " width:50px; " href = " ?userfeed=<?php echo $username ; ?> " title = " Your profile! " > Profile </ a >< br />
< a href = " index.php " > Feed </ a >< br />
< a href = " ?do=friends " > Friends </ a >< br />
< a href = " ?do=about " > About </ a >< br />
< a style = " width:50px; " href = " ?do=users " title = " Public users! " > Public figures </ a >< br />
< a style = " width:50px; " href = " ?do=userctrl " > Settings </ a >< br />
< a style = " width:50px; " href = " ?do=logout " > Log out </ a >< br />
2020-11-03 19:39:41 -08:00
< ? php } else { ?>
2021-02-13 17:27:03 -08:00
< a href = " ?forms=login " > Login </ a >< br />
< a href = " ?do=about " > About </ a >< br />
2020-11-03 19:39:41 -08:00
< ? php } ?>
2021-02-13 17:27:03 -08:00
</ div >
2020-11-03 19:39:41 -08:00
< ? php
2021-02-13 17:27:03 -08:00
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 " );
2020-11-03 19:39:41 -08:00
2021-02-13 17:27:03 -08:00
echo " <table class='notifications'><tr><td>Notifications: <a class='button' onclick= \" userClrNotifications(); \" >Clear</a></td></tr> " ;
2020-11-03 19:39:41 -08:00
2021-02-13 17:27:03 -08:00
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'> " ;
2020-11-03 19:39:41 -08:00
}
2021-02-13 17:27:03 -08:00
?>
< ? php
2020-11-03 19:39:41 -08:00
if ( isset ( $_GET [ 'forms' ]))
{
$forms = $_GET [ 'forms' ];
$id = $_GET [ 'pid' ];
if ( $forms == " register " ) {
registerForm ();
}
else if ( $forms == " login " ) {
loginForm ();
}
else if ( $forms == " friendreq " ) {
2021-02-13 17:27:03 -08:00
if ( $loginCheck == true ) {
friendReqForm ();
} else {
loginForm ();
}
2020-11-03 19:39:41 -08:00
}
else if ( $forms == " changepass " ) {
2021-02-13 17:27:03 -08:00
if ( $loginCheck == true ) {
changePassForm ();
} else {
loginForm ();
}
2020-11-03 19:39:41 -08:00
}
else if ( $forms == " deleteacct " ) {
2021-02-13 17:27:03 -08:00
if ( $loginCheck == true ) {
deleteAcctForm ();
} else {
loginForm ();
}
2020-11-03 19:39:41 -08:00
}
else if ( $forms == " avatarupload " ) {
2021-02-13 17:27:03 -08:00
if ( $loginCheck == true ) {
uploadAvatarForm ();
} else {
loginForm ();
}
2020-11-03 19:39:41 -08:00
}
else if ( $forms == " post " ) {
2021-02-13 17:27:03 -08:00
if ( $loginCheck == true ) {
postForm ();
} else {
loginForm ();
}
2020-11-03 19:39:41 -08:00
}
else if ( $forms == " clean " ) {
2021-02-13 17:27:03 -08:00
if ( $loginCheck == true ) {
cleanForm ();
} else {
loginForm ();
}
2020-11-03 19:39:41 -08:00
}
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 " ; }
2021-02-13 17:27:03 -08:00
else if ( $notify == " 7 " ) { echo " Error: Current password incorrect! " ; }
else if ( $notify == " 8 " ) { echo " Success! Current password changed! " ; }
2020-11-03 19:39:41 -08:00
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 " ) {
2021-02-13 17:27:03 -08:00
if ( $loginCheck == true ) {
2020-11-03 19:39:41 -08:00
$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;
2021-02-13 17:27:03 -08:00
unset ( $shared ); // Keep clean variables
2020-11-03 19:39:41 -08:00
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> " ;
}
2021-02-13 17:27:03 -08:00
if ( isset ( $shared ) && $shared == " 1 " )
{
echo " <br />Originally posted by $origowner " ;
}
echo " </span></h3></td></tr></table> " ;
2020-11-03 19:39:41 -08:00
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> " ;
2021-02-13 17:27:03 -08:00
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> " ;
2020-11-03 19:39:41 -08:00
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> " ;
}
2021-02-13 17:27:03 -08:00
if ( isset ( $shared ) && $shared == " 1 " )
{
echo " <br />Originally posted by $origowner " ;
}
echo " </span></h3></td></tr></table> " ;
2020-11-03 19:39:41 -08:00
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> " ;
2021-02-13 17:27:03 -08:00
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-o'></i> Delete</a> " ;
2020-11-03 19:39:41 -08:00
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> " ;
2021-02-13 17:27:03 -08:00
echo " <div class='avatar' style= \" background-image: url('index.php?do=avatarlocation&user= $userid '); \" title='User Avatar'></div> " ;
2020-11-03 19:39:41 -08:00
// 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 ;
2021-02-13 17:27:03 -08:00
unset ( $shared );
2020-11-03 19:39:41 -08:00
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> " ;
}
2021-02-13 17:27:03 -08:00
if ( isset ( $shared ) && $shared == " 1 " )
{
echo " <br />Originally posted by $origowner " ;
}
echo " </span></h3></td></tr></table> " ;
2020-11-03 19:39:41 -08:00
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> " ;
2021-02-13 17:27:03 -08:00
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> " ;
2020-11-03 19:39:41 -08:00
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> " ;
}
2021-02-13 17:27:03 -08:00
if ( isset ( $shared ) && $shared == " 1 " )
{
echo " <br />Originally posted by $origowner " ;
}
echo " </span></h3></td></tr></table> " ;
2020-11-03 19:39:41 -08:00
echo " " . bbcode_format ( $postcontent ) . " " ;
// Footer
2021-02-13 17:27:03 -08:00
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> " ;
2020-11-03 19:39:41 -08:00
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 style=' font - size : 8 px ; padding - left : 6 px ; color : #808080;'>$reply_date</span></h4></td></tr></table>";
echo " <div class='reply_content'> " . bbcode_format ( $reply_content ) . " </div> " ;
echo " </div> \n " ;
}
echo " <br /> " ;
2021-02-13 17:27:03 -08:00
if ( $loginCheck != true ) {
2020-11-03 19:39:41 -08:00
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 " )
{
2021-02-13 17:27:03 -08:00
if ( $loginCheck != true ) { loginForm (); } else {
2020-11-03 19:39:41 -08:00
$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 /> " ;
2021-02-13 17:27:03 -08:00
header ( " Location: index.php?view= $date &user= $username " );
2020-11-03 19:39:41 -08:00
}
else
{
echo " ERROR: Missing post data! Select an image to upload or let us know whats up!<br /> " ;
}
}
}
if ( $do == " avatarupload " )
{
2021-02-13 17:27:03 -08:00
if ( isset ( $_FILES [ " file " ][ " name " ]) && ( $loginCheck == true )) {
2020-11-03 19:39:41 -08:00
$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 " )
{
2021-02-13 17:27:03 -08:00
if ( $loginCheck != true ) { loginForm (); } else {
2020-11-03 19:39:41 -08:00
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 > " ;
2021-02-13 17:27:03 -08:00
header ( " Location:index.php?view= $pid &user= $postowner " );
2020-11-03 19:39:41 -08:00
}
else
{
echo " ERROR: Missing form data<br> " ;
}
}
}
}
if ( $do == " delpost " )
{
2021-02-13 17:27:03 -08:00
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 " );
2020-11-03 19:39:41 -08:00
exit ;
2021-02-13 17:27:03 -08:00
} 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! " ; }
2020-11-03 19:39:41 -08:00
}
}
if ( $do == " react " )
{
2021-02-13 17:27:03 -08:00
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 ;
2020-11-03 19:39:41 -08:00
}
}
2021-02-13 17:27:03 -08:00
fclose ( $handle );
} else {
echo " <!-- Haven't reacted, continuing --> " ;
}
2020-11-03 19:39:41 -08:00
2021-02-13 17:27:03 -08:00
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
}
2020-11-03 19:39:41 -08:00
2021-02-13 17:27:03 -08:00
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
}
2020-11-03 19:39:41 -08:00
2021-02-13 17:27:03 -08:00
// 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 );
}
2020-11-03 19:39:41 -08:00
2021-02-13 17:27:03 -08:00
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! " ; }
2020-11-03 19:39:41 -08:00
}
}
if ( $do == " clrnote " )
{
2021-02-13 17:27:03 -08:00
if ( $loginCheck != true ) { loginForm (); } else {
unlink ( " ssb_db/friends/ " . $username . " .notifications " );
header ( " Location: index.php " );
exit ;
}
2020-11-03 19:39:41 -08:00
}
if ( $do == " clrpending " )
{
2021-02-13 17:27:03 -08:00
if ( $loginCheck != true ) { loginForm (); } else {
unlink ( " ssb_db/friends/ " . $username . " .pending " );
header ( " Location: index.php?do=friends " );
exit ;
2020-11-03 19:39:41 -08:00
}
}
// 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 " ) {
2021-02-13 17:27:03 -08:00
if ( $loginCheck != true ) { loginForm (); } else {
2020-11-03 19:39:41 -08:00
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... " ;
}
}
}
2021-02-13 17:27:03 -08:00
if ( $do == " accfr " )
{
if ( $loginCheck != true ) { loginForm (); } else {
if ( isset ( $_GET [ 'user' ]) && isset ( $_GET [ 'friend' ])) {
acceptFriendRequest ( stripslashes ( $_GET [ 'user' ]), stripslashes ( $_GET [ 'friend' ]));
2020-11-03 19:39:41 -08:00
echo " Accepted friend request from " . htmlentities ( stripslashes ( $_GET [ 'friend' ])) . " <a href='?do=friends'>redirecting</a> in 3 seconds " ;
header ( " refresh: 3;url=?do=friends " );
2021-02-13 17:27:03 -08:00
} else {
echo " Error: users not set in GET & SESSION value... " ;
}
}
}
2020-11-03 19:39:41 -08:00
if ( $do == " userctrl " )
{
2021-02-13 17:27:03 -08:00
if ( $loginCheck != true ) { loginForm (); } else {
// Beginning of user control panel
2020-11-03 19:39:41 -08:00
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 /> " ;
2021-02-13 17:27:03 -08:00
}
2020-11-03 19:39:41 -08:00
}
if ( $do == " changepass " )
{
2021-02-13 17:27:03 -08:00
if ( $loginCheck != true ) { loginForm (); } else {
2020-11-03 19:39:41 -08:00
// 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 " ); }
}
}
2021-02-13 17:27:03 -08:00
if ( $do == " privmsg " )
2020-11-03 19:39:41 -08:00
{
2021-02-13 17:27:03 -08:00
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 }) {
2020-11-03 19:39:41 -08:00
?>
< script language = " javascript " type = " text/javascript " >
<!--
var httpObject = null ;
var link = " " ;
var timerID = 0 ;
2021-02-13 17:27:03 -08:00
var friendNick = " <?php echo $friendNick ; ?> " ;
2020-11-03 19:39:41 -08:00
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 ) {
2021-02-13 17:27:03 -08:00
link = " chatserver.php?nick= " + nickName + " &friend= " + friendNick + " &msg= " + document . getElementById ( 'msg' ) . value ;
2020-11-03 19:39:41 -08:00
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 ) {
2021-02-13 17:27:03 -08:00
link = " chatserver.php?get=<?php echo $friendNick ; ?> " ;
2020-11-03 19:39:41 -08:00
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 " >
2021-02-13 17:27:03 -08:00
< ? php
// Header
include " ssb_db/users/ " . $friendNick . " .php " ;
echo " <h3><a href='?userfeed= " . $friendNick . " '> " . $friendNick . " : " . $user_fullname . " </a></h3> " ;
?>
2020-11-03 19:39:41 -08:00
< div id = " msgs " >
< ? php
echo " <div class= \" msgbox \" > " ;
echo " </div> " ;
?>
</ div >
< div id = " msgbox " onkeyup = " keypressed(event); " >
2021-02-13 17:27:03 -08:00
< button onclick = " javascript:wrapBBCode('i'); " > Italic </ button >
2020-11-03 19:39:41 -08:00
< button onclick = " javascript:wrapBBCode('u'); " > Underline </ button >
< button onclick = " javascript:wrapBBCode('b'); " > Bold </ button >
2021-02-13 17:27:03 -08:00
< button onclick = " javascript:wrapBBCode('img'); " > Image </ button >
2020-11-03 19:39:41 -08:00
< button onclick = " javascript:wrapBBCode('url'); " > URL </ button >< br />
2021-02-13 17:27:03 -08:00
< textarea style = " width: 98%; " name = " msg " id = " msg " ></ textarea >
< button style = " width: 50px; " onclick = " getInput(); " > Send </ button >
</ div >
2020-11-03 19:39:41 -08:00
</ div >
< ? php
2021-02-13 17:27:03 -08:00
} // Check friend end
} // Check loop end
} // GET friend set end
} // session check end
} // function end
2020-11-03 19:39:41 -08:00
2021-02-13 17:27:03 -08:00
if ( $do == " msghist " )
2020-11-03 19:39:41 -08:00
{
2021-02-13 17:27:03 -08:00
if ( $loginCheck != true ) { loginForm (); } else {
2020-11-03 19:39:41 -08:00
//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 ;
2021-02-13 17:27:03 -08:00
var link = " chatserver.php?get=<?php echo $friendNick ; ?> " ;
2020-11-03 19:39:41 -08:00
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 ;
}
}
2021-02-13 17:27:03 -08:00
function serverLoad () {
2020-11-03 19:39:41 -08:00
ajaxVar = getHTTPObject ();
//var randomnumber=Math.floor(Math.random()*10000);
if ( ajaxVar != null ) {
ajaxVar . open ( " GET " , link , true );
ajaxVar . onreadystatechange = setAll ;
ajaxVar . send ( null );
}
}
2021-02-13 17:27:03 -08:00
window . addEventListener ( 'load' , function () {
serverLoad ();
});
2020-11-03 19:39:41 -08:00
//-->
</ script >
< div class = " replycontain " >
< ? php
// Header
include " ssb_db/users/ " . $friendNick . " .php " ;
2021-02-13 17:27:03 -08:00
echo " <h3><a href='?userfeed= " . $friendNick . " '> " . $friendNick . " : Message history</a></h3> " ;
2020-11-03 19:39:41 -08:00
?>
< div id = " msgs " >
< ? php
2021-02-13 17:27:03 -08:00
echo " <div class= \" msgbox \" style= \" overflow-y: scroll; \" > " ;
2020-11-03 19:39:41 -08:00
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.0.0.apk'>Download for Android!</a></div> " ;
echo " <p> " . $desc ;
echo " <br /><br /> " ;
echo " $ssbtitle statistics: " ;
getUserCount ();
echo " ; " ;
getPostCount ();
echo " ; " ;
getUploadFileCount ();
echo " </p> " ;
}
2021-02-13 17:27:03 -08:00
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> " ;
}
}
}
}
2020-11-03 19:39:41 -08:00
if ( $do == " friends " )
{
2021-02-13 17:27:03 -08:00
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> " ;
2020-11-03 19:39:41 -08:00
// Friends list if you have any.
2021-02-13 17:27:03 -08:00
echo " <br /> " ;
2020-11-03 19:39:41 -08:00
$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 ++ )
{
2021-02-13 17:27:03 -08:00
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> " ;
2020-11-03 19:39:41 -08:00
}
}
echo " </table> " ;
}
}
}
if ( $do == " login " )
{
$username = $_POST [ 'username' ];
2021-02-13 17:27:03 -08:00
if ( file_exists ( " ssb_db/users/ $username .php " )) {
2020-11-03 19:39:41 -08:00
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! " ;
}
}
2021-02-13 17:27:03 -08:00
2020-11-03 19:39:41 -08:00
if ( $do == " logout " )
{
2021-02-13 17:27:03 -08:00
$_SESSION [ 'ssb-user' ] = null ;
$_SESSION [ 'ssb-pass' ] = null ;
2020-11-03 19:39:41 -08:00
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 " );
}
2021-02-13 17:27:03 -08:00
echo " <b>ERROR!</b>: Something weird just happened... please try registering again!!!... " ;
//header("Location: index.php");
2020-11-03 19:39:41 -08:00
}
}
2021-02-13 17:27:03 -08:00
else if ( $loginCheck != true )
2020-11-03 19:39:41 -08:00
{
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 ) {
2021-02-13 17:27:03 -08:00
unset ( $shared ); // make sure its not being carried over after loop.
2020-11-03 19:39:41 -08:00
$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> " ;
}
2021-02-13 17:27:03 -08:00
if ( isset ( $shared ) && $shared == " 1 " )
{
echo " <br />Originally posted by $origowner " ;
}
echo " </span></h3></td></tr></table> " ;
2020-11-03 19:39:41 -08:00
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> " ;
2021-02-13 17:27:03 -08:00
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> " ;
2020-11-03 19:39:41 -08:00
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> " ;
}
2021-02-13 17:27:03 -08:00
if ( isset ( $shared ) && $shared == " 1 " )
{
echo " <br />Originally posted by $origowner " ;
}
echo " </span></h3></td></tr></table> " ;
2020-11-03 19:39:41 -08:00
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> " ;
2021-02-13 17:27:03 -08:00
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> " ;
2020-11-03 19:39:41 -08:00
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 " ;
2021-02-13 17:27:03 -08:00
2020-11-03 19:39:41 -08:00
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> " ;
}
2021-02-13 17:27:03 -08:00
if ( isset ( $shared ) && $shared == " 1 " )
{
echo " <br />Originally posted by $origowner " ;
}
echo " </span></h3></td></tr></table> " ;
2020-11-03 19:39:41 -08:00
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> " ;
2021-02-13 17:27:03 -08:00
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-o'></i> Delete</a> " ;
2020-11-03 19:39:41 -08:00
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> " ;
}
2021-02-13 17:27:03 -08:00
echo " </span></h3></td></tr></table> " ;
2020-11-03 19:39:41 -08:00
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> " ;
2021-02-13 17:27:03 -08:00
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-o'></i> Delete</a> " ;
2020-11-03 19:39:41 -08:00
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> " ;
}
?>
2021-02-13 17:27:03 -08:00
</ td ></ tr ></ table >
< div id = " footer " > Powered By SSB < ? php echo $version ; ?> </div>
2020-11-03 19:39:41 -08:00
</ div >
2021-02-13 17:27:03 -08:00
<!-- functions -->
< script type = " text/javascript " src = " data/main.js " ></ script >
2020-11-03 19:39:41 -08:00
</ body >
</ html >