Login
New to ? No problem,
register
here and get started!
EOD;
}*/
function registerForm() {
?>
Create a post
EOD;
}
function replyForm($id, $puser) {
?>
Send a friend request
";
exit(1);
}
// Check if user is itself
if($user == $friend) { header("Location: index.php?do=friends"); exit(1); } // dont request from self.
$friendc = file_get_contents("ssb_db/friends/" . $user . ".count");
$friendcount = file_get_contents("ssb_db/friends/" . $user . ".count");
include "ssb_db/friends/" . $user . ".php";
for($x = 1; $x <= $friendcount; $x++)
{
if(${"friend" . $x} == $friend) { header("Location: index.php?do=friends"); echo "Already following!"; exit(1); }
}
if(file_exists($friendLocation)) {
$notifications = file_get_contents($friendLocation);
file_put_contents("ssb_db/friends/" . $friend . ".notifications", "Friend request from " . $user . "! Accept?" . "\n" . $notifications);
} else {
file_put_contents("ssb_db/friends/" . $friend . ".notifications", "Friend request from " . $user . "! Accept?");
}
if(file_exists($friendPending)) {
$pending = file_get_contents($friendPending);
file_put_contents("ssb_db/friends/" . $friend . ".pending", $user . "\n" . $pending);
} else {
file_put_contents("ssb_db/friends/" . $friend . ".pending", $user);
}
}
function acceptPublicFriendRequest($user, $friend) {
$friendpending = "ssb_db/friends/" . $user . ".pending";
$friendlist = file_get_contents("ssb_db/friends/" . $user . ".php");
$frienddb = file_get_contents("ssb_db/friends/" . $friend . ".php");
// check if already on friends list.
$friendc = file_get_contents("ssb_db/friends/" . $user . ".count");
$friendcount = file_get_contents("ssb_db/friends/" . $user . ".count");
include "ssb_db/friends/" . $user . ".php";
for($x = 1; $x <= $friendcount; $x++)
{
if(${"friend" . $x} == $friend) { echo "Already following!"; exit(1); }
}
// populate both users databases with each other.
$friendcountFriend = file_get_contents("ssb_db/friends/" . $friend . ".count");
$friendcountFriend = $friendcountFriend + 1;
//echo $friendcountFriend;
file_put_contents("ssb_db/friends/" . $friend . ".php", $frienddb . "\n ");
$friendcount = file_get_contents("ssb_db/friends/" . $user . ".count");
$friendcount = $friendcount + 1;
//echo $friendcount;
file_put_contents("ssb_db/friends/" . $user . ".php", $friendlist . "\n ");
file_put_contents("ssb_db/friends/" . $user . ".count", $friendcount);
file_put_contents("ssb_db/friends/" . $friend . ".count", $friendcountFriend);
file_put_contents("ssb_db/friends/" . $user . $friend . ".count", "1");
file_put_contents("ssb_db/friends/" . $user . $friend . ".php", "\";?>");
}
function acceptFriendRequest($user, $friend) {
$friendpending = "ssb_db/friends/" . $user . ".pending";
$friendlist = file_get_contents("ssb_db/friends/" . $user . ".php");
$frienddb = file_get_contents("ssb_db/friends/" . $friend . ".php");
// check if friend request is really pending.
$friendc = file_get_contents("ssb_db/friends/" . $user . ".count");
include "ssb_db/friends/" . $user . ".php";
for($x = 1; $x <= $friendc; $x++)
{
if(${"friend" . $x} == $friend) { echo "Already following!"; exit(1); }
}
$handle = fopen($friendpending, "r");
if ($handle) {
$xx = 0;
while (($line = fgets($handle)) !== false) {
if($xx >= "1") {
$line = str_replace("\n","",$line);
}
$xx++;
//echo $line . "
";
//echo $friend . "
";
if($friend == $line)
{
// populate both users databases with each other.
$friendcountFriend = file_get_contents("ssb_db/friends/" . $friend . ".count");
$friendcountFriend = $friendcountFriend + 1;
//echo $friendcountFriend;
file_put_contents("ssb_db/friends/" . $friend . ".php", $frienddb . "\n ");
$friendcount = file_get_contents("ssb_db/friends/" . $user . ".count");
$friendcount = $friendcount + 1;
//echo $friendcount;
file_put_contents("ssb_db/friends/" . $user . ".php", $friendlist . "\n ");
file_put_contents("ssb_db/friends/" . $user . ".count", $friendcount);
file_put_contents("ssb_db/friends/" . $friend . ".count", $friendcountFriend);
file_put_contents("ssb_db/friends/" . $user . $friend . ".count", "1");
file_put_contents("ssb_db/friends/" . $user . $friend . ".php", "\";?>");
}
}
fclose($handle);
} else {
echo "ERROR: Friend: " . $friend . " not found in friend pending database.
";
}
}
?>