Big changes
This commit is contained in:
parent
a26c3de40a
commit
ed9fbba4a3
17
bbcode.php
17
bbcode.php
@ -8,8 +8,17 @@
|
||||
// modified by www.vision.to
|
||||
// please keep credits, thank you :-)
|
||||
// document your changes.
|
||||
function bbcode_format($str) {
|
||||
|
||||
function convertYoutubeURL($string) {
|
||||
preg_match(
|
||||
'/[\\?\\&]v=([^\\?\\&]+)/',
|
||||
$string,
|
||||
$matches
|
||||
);
|
||||
$id = $matches[0];
|
||||
return $id;
|
||||
}
|
||||
|
||||
function bbcode_format($str) {
|
||||
$simple_search = array(
|
||||
'/\[b\](.*?)\[\/b\]/is',
|
||||
'/\*\*\*(.*?)\*\*\*/is',
|
||||
@ -20,7 +29,8 @@ function bbcode_format($str) {
|
||||
'/\[img\](.*?)\[\/img\]/is',
|
||||
'/\[url\](.*?)\[\/url\]/is',
|
||||
'/\[font\=(.*?)\](.*?)\[\/font\]/is',
|
||||
'/\[color\=(.*?)\](.*?)\[\/color\]/is',
|
||||
'/\[color\=(.*?)\](.*?)\[\/color\]/is',
|
||||
'~\[youtube]https?.*?(?:[/?&](?:e|vi?|ci)(?:[/=]|%3D)|youtu\.be/|embed/|/user/[^/]+#p/(?:[^/]+/)+)([\w-]{10,12}).*?\[/youtube]~i'
|
||||
);
|
||||
|
||||
$simple_replace = array(
|
||||
@ -34,6 +44,7 @@ function bbcode_format($str) {
|
||||
"<a href='$1' title='$1'>$1</a>",
|
||||
"<span style='font-family: $1;'>$2</span>",
|
||||
"<span style='color: $1;'>$2</span>",
|
||||
"<iframe width='560' height='315' src='https://youtube.com/embed/$1' frameborder='0' allow='accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture' allowfullscreen></iframe>",
|
||||
);
|
||||
|
||||
// Do simple BBCode's
|
||||
|
@ -8,23 +8,7 @@ include("bbcode.php");
|
||||
|
||||
if (!isset($_SESSION['ssb-user']) && !isset($_SESSION['ssb-pass'])) { echo "ERROR: Not logged in!"; header("Location: index.php"); exit(1); }
|
||||
|
||||
if (isset($_GET['msg']) && $_GET['msg']!="" && isset($_GET['nick']) && !isset($_GET['friend'])){
|
||||
|
||||
$nick = $_GET['nick'];
|
||||
$msg = bbcode_format(nl2br(htmlentities(stripcslashes($_GET['msg']))));
|
||||
$line = "<table><tr><td style='vertical-align: top;'><img class='avatar_chat' src='?do=avatarlocation&user=" . $nick . "' title='User Avatar'></td><td class='message'><b>$nick</b>: $msg</td></tr></table>\n";
|
||||
$old_content = file_get_contents($chat_db);
|
||||
|
||||
$lines = count(file($chat_db));
|
||||
|
||||
if($lines>$server_msgcount) {
|
||||
$old_content = implode("\n", array_slice(explode("\n", $old_content), 1));
|
||||
}
|
||||
|
||||
file_put_contents($chat_db, $old_content.$line);
|
||||
echo $line;
|
||||
|
||||
} else if (isset($_GET['msg']) && $_GET['msg']!="" && isset($_GET['nick']) && isset($_GET['friend'])){
|
||||
if (isset($_GET['msg']) && $_GET['msg']!="" && isset($_GET['nick']) && isset($_GET['friend'])){
|
||||
|
||||
$friendNick = $_GET['friend'];
|
||||
$nick = $_SESSION['ssb-user'];
|
||||
@ -39,7 +23,7 @@ if (isset($_GET['msg']) && $_GET['msg']!="" && isset($_GET['nick']) && !isset($_
|
||||
$msgCount = file_get_contents("ssb_db/friends/" . ${"friend_chat_db" . $x} . ".count");
|
||||
$msgCount = $msgCount + 1;
|
||||
$msg = bbcode_format(nl2br(htmlentities(stripcslashes($_GET['msg']))));
|
||||
$line_start = "<?php \$msg" . $msgCount . " = \"<table><tr><td style='vertical-align: top;'><img class='avatar_chat' src='?do=avatarlocation&user=" . $nick . "' title='User Avatar'></td><td class='message'><b>$nick</b>: $msg</td></tr></table>";
|
||||
$line_start = "<?php \$msg" . $msgCount . " = \"<table><tr><td style='vertical-align: top;'><img class='avatar_chat' src='index.php?do=avatarlocation&user=" . $nick . "' title='User Avatar'></td><td class='message'><b>$nick</b>: $msg</td></tr></table>";
|
||||
$line_end = "\"; ?>\n";
|
||||
|
||||
$old_content = file_get_contents("ssb_db/friends/" . ${"friend_chat_db" . $x} . ".php");
|
||||
@ -70,20 +54,5 @@ if (isset($_GET['msg']) && $_GET['msg']!="" && isset($_GET['nick']) && !isset($_
|
||||
} //else { echo "Not friend!"; }
|
||||
//echo "Finding friend in slot " . $x;
|
||||
}
|
||||
} else if (isset($_GET['all'])) {
|
||||
//$content = file_get_contents($server_db);
|
||||
// This is faster
|
||||
$flag = file($chat_db);
|
||||
$content = "";
|
||||
foreach ($flag as $value) {
|
||||
$content .= $value;
|
||||
}
|
||||
echo $content;
|
||||
|
||||
}/* else if(isset($_GET['ping'])) {
|
||||
$username = $_GET['nick'];
|
||||
|
||||
} else if(isset($_GET['pong'])) {
|
||||
|
||||
}*/
|
||||
}
|
||||
?>
|
||||
|
12
config.php
12
config.php
@ -6,13 +6,13 @@
|
||||
// Version: 2.1.0
|
||||
///////
|
||||
|
||||
$title = "Simple Social Board"; // SM title
|
||||
$desc = "Simple open source social media platform"; // platform description
|
||||
$domain = "sm.cddo.cf"; // where is SSB operating?
|
||||
$admin = "Username"; // Administrator account username
|
||||
$ssbtitle = "Secure Space"; // SM title
|
||||
$desc = "Simple, ad-free, yet flexible social media platform to the user; for the user! " . $ssbtitle . " is powered by SSB.<br /><br />With a fresh account, you'll need to send invites to friends that use this platform! After the friend requests are accepted, you'll have view of feed posts from friends including yourself by timestamp newest to oldest.<br /><b>NOTE:</b> The chat room is in no way private, and can be seen by anyone with an account! Please be cautious and safe online! Private messages are user to user and are safe with us!"; // platform description
|
||||
$domain = "secure.space.cddo.cc"; // where is SSB operating?
|
||||
$admin = "Chraas"; // Administrator account username
|
||||
$version = "2.1.0"; // version
|
||||
$chat_db = "ssb_db/friends/chatdb.txt"; //public chat db
|
||||
$chat_db = "ssb_db/friends/chatdb.txt"; //Temp chat db
|
||||
$server_msgcount = "52"; // for chat page
|
||||
$user_max_upload = "4194304";
|
||||
$user_max_upload = "422194304";
|
||||
|
||||
?>
|
||||
|
54
data/main.js
Normal file
54
data/main.js
Normal file
@ -0,0 +1,54 @@
|
||||
var elems = document.body.getElementsByTagName("video");
|
||||
for(var i = 0; i < elems.length; i++)
|
||||
{
|
||||
elems[i].setAttribute("preload","none");
|
||||
}
|
||||
|
||||
// Get the HTTP Object
|
||||
function getHTTPObject() {
|
||||
if (window.ActiveXObject) return new ActiveXObject("Microsoft.XMLHTTP");
|
||||
else if (window.XMLHttpRequest) return new XMLHttpRequest();
|
||||
else {
|
||||
alert("Your browser does not support AJAX.");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
function wrapBBCode(tag) {
|
||||
var msgInput = document.getElementById('msg');
|
||||
var content = msgInput.value;
|
||||
var selectedContent = content.substring(msgInput.selectionStart, msgInput.selectionEnd);
|
||||
var beforeContent = content.substring(0, msgInput.selectionStart);
|
||||
var afterContent = content.substring(msgInput.selectionEnd, content.length);
|
||||
msgInput.value = beforeContent + '[' + tag + ']' + selectedContent + '[/' + tag + ']' + afterContent;
|
||||
}
|
||||
|
||||
function userTag(tag) {
|
||||
var msgInput = document.getElementById('msg');
|
||||
var content = msgInput.value;
|
||||
var beforeContent = content.substring(0, msgInput.selectionStart);
|
||||
var afterContent = content.substring(msgInput.selectionEnd, content.length);
|
||||
msgInput.value = beforeContent + '@' + tag + afterContent;
|
||||
}
|
||||
|
||||
// For dynamic reacting without leaving page.
|
||||
function userReact(user, postid) {
|
||||
ajaxGet = getHTTPObject();
|
||||
if (ajaxGet != null) {
|
||||
link = "index.php?do=react&user="+user+"&pid="+postid;
|
||||
ajaxGet.open("GET", link , true);
|
||||
ajaxGet.send(null);
|
||||
setTimeout(function(){ window.location.reload(); }, 1000);
|
||||
}
|
||||
}
|
||||
|
||||
// For dynamic reacting without leaving page.
|
||||
function userClrNotifications() {
|
||||
ajaxGet = getHTTPObject();
|
||||
if (ajaxGet != null) {
|
||||
link = "index.php?do=clrnote";
|
||||
ajaxGet.open("GET", link , true);
|
||||
ajaxGet.send(null);
|
||||
setTimeout(function(){ window.location.reload(); }, 1000);
|
||||
}
|
||||
}
|
22
data/upload.js
Executable file
22
data/upload.js
Executable file
@ -0,0 +1,22 @@
|
||||
const url = 'chatserver.php?do=upload'
|
||||
const form = document.querySelector('form')
|
||||
|
||||
form.addEventListener('submit', (e) => {
|
||||
e.preventDefault()
|
||||
|
||||
const files = document.querySelector('[type=file]').files
|
||||
const formData = new FormData()
|
||||
|
||||
for (let i = 0; i < files.length; i++) {
|
||||
let file = files[i]
|
||||
|
||||
formData.append('files[]', file)
|
||||
}
|
||||
|
||||
fetch(url, {
|
||||
method: 'POST',
|
||||
body: formData,
|
||||
}).then((response) => {
|
||||
console.log(response)
|
||||
})
|
||||
})
|
267
forms.php
267
forms.php
@ -1,267 +0,0 @@
|
||||
<?php
|
||||
// SSB - Simple Social Board
|
||||
// (C) Chris Dorman, 2012 - 2020
|
||||
// License: CC-BY-NC-SA version 3.0
|
||||
// http://github.com/Pentium44/SSB
|
||||
|
||||
// get filesize for uploaded files
|
||||
function tomb($size, $precision = 2)
|
||||
{
|
||||
$base = log($size) / log(1024);
|
||||
$suffixes = array('', 'KB', 'MB', 'GB', 'TB');
|
||||
|
||||
return round(pow(1024, $base - floor($base)), $precision) . $suffixes[floor($base)];
|
||||
}
|
||||
|
||||
function loginForm() {
|
||||
?>
|
||||
<br />
|
||||
<div class="login">
|
||||
<a class="button" href="<?php echo $_SERVER['PHP_SELF']; ?>?forms=register">Register</a>
|
||||
<form action="<?php echo $_SERVER['PHP_SELF']; ?>?do=login" method="post">
|
||||
<table><tr><td>
|
||||
Username:</td><td> <input class="text" type="text" name="username"></td></tr><tr><td>
|
||||
Password:</td><td> <input class="text" type="password" name="password"></td></tr></table>
|
||||
<input style="padding: 2px;" class="text" type="submit" name="submitBtn" value="Login">
|
||||
</form>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
function changePassForm() {
|
||||
?>
|
||||
<br />
|
||||
<div class="chgpass">
|
||||
<form action="<?php echo $_SERVER['PHP_SELF']; ?>?do=changepass" method="post">
|
||||
<table><tr><td>
|
||||
Old password:</td><td> <input class="text" type="password" name="oldpass"></td></tr><tr><td>
|
||||
Password:</td><td> <input class="text" type="password" name="password"></td></tr><tr><td>
|
||||
Password Again:</td><td> <input class="text" type="password" name="password_again"></td></tr>
|
||||
</table>
|
||||
<input class="text" type="submit" name="submitBtn" value="Change">
|
||||
</form>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
function uploadAvatarForm() {
|
||||
?>
|
||||
<br />
|
||||
<div class="upload">
|
||||
<form action="<?php echo $_SERVER['PHP_SELF']; ?>?do=avatarupload" method="post" enctype="multipart/form-data">
|
||||
Choose profile avatar: <br />
|
||||
<label class="input-upload">
|
||||
<input type="file" name="file[]" id="file" multiple>
|
||||
<i class="fa fa-cloud-upload"></i> Upload image
|
||||
</label>
|
||||
<input class="text" type="submit" name="submit" value="Set">
|
||||
</form>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
|
||||
/*function uploadForm() {
|
||||
|
||||
print <<<EOD
|
||||
Upload
|
||||
<table style="margin:auto;">
|
||||
|
||||
<form action="upload.php" method="post" enctype="multipart/form-data">
|
||||
<tr>
|
||||
<td>
|
||||
<input type="file" name="file[]" id="file" multiple><br>
|
||||
</td>
|
||||
<td>
|
||||
<input type="submit" name="submit" value="Upload">
|
||||
</td>
|
||||
</tr>
|
||||
</form>
|
||||
|
||||
</table>
|
||||
EOD;
|
||||
|
||||
}*/
|
||||
|
||||
function registerForm() {
|
||||
?>
|
||||
<br />
|
||||
<div class="login">
|
||||
<form action="<?php echo $_SERVER['PHP_SELF']; ?>?do=register" method="post">
|
||||
<table><tr><td>
|
||||
Username:</td><td> <input class="text" type="text" name="username"></td></tr><tr><td>
|
||||
Full name:</td><td> <input class="text" type="text" name="fullname"></td></tr><tr><td>
|
||||
Password:</td><td> <input class="text" type="password" name="password"></td></tr><tr><td>
|
||||
Password Again:</td><td> <input class="text" type="password" name="password-again"></td></tr><tr><td>
|
||||
<label for="acct">Profile type:</label>
|
||||
<select id="acct" name="acct">
|
||||
<option value="private">Private</option>
|
||||
<option value="public">Public</option>
|
||||
</select></td><td>
|
||||
<input class="text" type="submit" name="submitBtn" value="Register">
|
||||
</td></tr></table>
|
||||
</form>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
function postForm() {
|
||||
print <<<EOD
|
||||
<button onclick="javascript:wrapBBCode('i');">Italic</button>
|
||||
<button onclick="javascript:wrapBBCode('u');">Underline</button>
|
||||
<button onclick="javascript:wrapBBCode('b');">Bold</button>
|
||||
<button onclick="javascript:wrapBBCode('url');">URL</button>
|
||||
<form action="?do=post" method="post" enctype="multipart/form-data">
|
||||
<label class="input-upload">
|
||||
<input type="file" name="file[]" id="file" multiple>
|
||||
<i class="fa fa-cloud-upload"></i> Upload image
|
||||
</label>
|
||||
<br /><textarea rows="5" cols="60" id="msg" name="body"></textarea><br />
|
||||
<input type="submit" name="post" value="Post">
|
||||
</form>
|
||||
EOD;
|
||||
}
|
||||
|
||||
function replyForm($id, $puser) {
|
||||
?>
|
||||
<button onclick="javascript:wrapBBCode('i');">Italic</button>
|
||||
<button onclick="javascript:wrapBBCode('u');">Underline</button>
|
||||
<button onclick="javascript:wrapBBCode('b');">Bold</button>
|
||||
<button onclick="javascript:wrapBBCode('url');">URL</button>
|
||||
<form action="?do=reply&pid=<?php echo $id; ?>&user=<?php echo $puser; ?>" method="post">
|
||||
<textarea rows="7" cols="60" id="msg" name="body">Reply</textarea><br />
|
||||
<input type="submit" name="reply" value="Reply">
|
||||
</form>
|
||||
<?php
|
||||
|
||||
}
|
||||
|
||||
function cleanForm() {
|
||||
?>
|
||||
|
||||
<br />
|
||||
<form action="?do=clean" method="post">
|
||||
Password: <input type="password" name="password" id="password"> <br />
|
||||
<input type="submit" name="post" value="Post">
|
||||
</form>
|
||||
<?php
|
||||
}
|
||||
|
||||
function friendReqForm() {
|
||||
?>
|
||||
|
||||
<h2>Request friendship!</h2>
|
||||
<form action="?do=sendfr" method="post">
|
||||
Username: <input type="text" name="user" id="user"> <br />
|
||||
<input type="submit" name="post" value="Send">
|
||||
</form>
|
||||
<?php
|
||||
}
|
||||
|
||||
|
||||
function sendFriendRequest($user, $friend) {
|
||||
$friendLocation = "ssb_db/friends/" . $friend . ".pending";
|
||||
$handle = fopen($friendLocation, "r");
|
||||
if ($handle) {
|
||||
while (($line = fgets($handle)) !== false) {
|
||||
if($line == $user) { break; } // request already pending
|
||||
}
|
||||
fclose($handle);
|
||||
}
|
||||
|
||||
// Check if user is itself
|
||||
if($user == $friend) { header("Location: index.php?do=friends"); exit(1); } // dont request from self.
|
||||
|
||||
$friendc = file_get_contents("ssb_db/friends/" . $user . ".count");
|
||||
$friendcount = file_get_contents("ssb_db/friends/" . $user . ".count");
|
||||
include "ssb_db/friends/" . $user . ".php";
|
||||
for($x = 1; $x <= $friendcount; $x++)
|
||||
{
|
||||
if(${"friend" . $x} == $friend) { header("Location: index.php?do=friends"); echo "Already following!"; exit(1); }
|
||||
}
|
||||
|
||||
if(file_exists($friendLocation)) {
|
||||
$pending = file_get_contents("ssb_db/friends/" . $friend . ".pending");
|
||||
file_put_contents("ssb_db/friends/" . $friend . ".pending", $pending . "\n" . $user);
|
||||
} else {
|
||||
file_put_contents("ssb_db/friends/" . $friend . ".pending", $user);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function acceptPublicFriendRequest($user, $friend) {
|
||||
$friendpending = "ssb_db/friends/" . $user . ".pending";
|
||||
$friendlist = file_get_contents("ssb_db/friends/" . $user . ".php");
|
||||
$frienddb = file_get_contents("ssb_db/friends/" . $friend . ".php");
|
||||
// check if already on friends list.
|
||||
|
||||
$friendc = file_get_contents("ssb_db/friends/" . $user . ".count");
|
||||
$friendcount = file_get_contents("ssb_db/friends/" . $user . ".count");
|
||||
include "ssb_db/friends/" . $user . ".php";
|
||||
for($x = 1; $x <= $friendcount; $x++)
|
||||
{
|
||||
if(${"friend" . $x} == $friend) { echo "Already following!"; exit(1); }
|
||||
}
|
||||
|
||||
// populate both users databases with each other.
|
||||
$friendcountFriend = file_get_contents("ssb_db/friends/" . $friend . ".count");
|
||||
$friendcountFriend = $friendcountFriend + 1;
|
||||
//echo $friendcountFriend;
|
||||
file_put_contents("ssb_db/friends/" . $friend . ".php", $frienddb . "\n <?php \$friend" . $friendcountFriend ." = \"" . $user . "\";\n\$friend_chat_db" . $friendcountFriend . " = \"" . $user . $friend . "\";?>");
|
||||
$friendcount = file_get_contents("ssb_db/friends/" . $user . ".count");
|
||||
$friendcount = $friendcount + 1;
|
||||
//echo $friendcount;
|
||||
file_put_contents("ssb_db/friends/" . $user . ".php", $friendlist . "\n <?php \$friend" . $friendcount . " = \"" . $friend . "\";\n\$friend_chat_db" . $friendcount . " = \"" . $user . $friend . "\";?>");
|
||||
file_put_contents("ssb_db/friends/" . $user . ".count", $friendcount);
|
||||
file_put_contents("ssb_db/friends/" . $friend . ".count", $friendcountFriend);
|
||||
file_put_contents("ssb_db/friends/" . $user . $friend . ".count", "1");
|
||||
file_put_contents("ssb_db/friends/" . $user . $friend . ".php", "<?php \$msg1 = \"" . $user . " and " . $friend . " are now friends!<br />\";?>");
|
||||
|
||||
}
|
||||
|
||||
function acceptFriendRequest($user, $friend) {
|
||||
$friendpending = "ssb_db/friends/" . $user . ".pending";
|
||||
$friendlist = file_get_contents("ssb_db/friends/" . $user . ".php");
|
||||
$frienddb = file_get_contents("ssb_db/friends/" . $friend . ".php");
|
||||
// check if friend request is really pending.
|
||||
|
||||
$friendc = file_get_contents("ssb_db/friends/" . $user . ".count");
|
||||
include "ssb_db/friends/" . $user . ".php";
|
||||
for($x = 1; $x <= $friendc; $x++)
|
||||
{
|
||||
if(${"friend" . $x} == $friend) { echo "Already following!"; exit(1); }
|
||||
}
|
||||
|
||||
$handle = fopen($friendpending, "r");
|
||||
if ($handle) {
|
||||
$xx = 0;
|
||||
while (($line = fgets($handle)) !== false) {
|
||||
if($xx >= "1") {
|
||||
$line = str_replace("\n","",$line);
|
||||
}
|
||||
$xx++;
|
||||
//echo $line . "<br />";
|
||||
//echo $friend . "<br />";
|
||||
if($friend == $line)
|
||||
{
|
||||
// populate both users databases with each other.
|
||||
$friendcountFriend = file_get_contents("ssb_db/friends/" . $friend . ".count");
|
||||
$friendcountFriend = $friendcountFriend + 1;
|
||||
//echo $friendcountFriend;
|
||||
file_put_contents("ssb_db/friends/" . $friend . ".php", $frienddb . "\n <?php \$friend" . $friendcountFriend ." = \"" . $user . "\";\n\$friend_chat_db" . $friendcountFriend . " = \"" . $user . $friend . "\";?>");
|
||||
$friendcount = file_get_contents("ssb_db/friends/" . $user . ".count");
|
||||
$friendcount = $friendcount + 1;
|
||||
//echo $friendcount;
|
||||
file_put_contents("ssb_db/friends/" . $user . ".php", $friendlist . "\n <?php \$friend" . $friendcount . " = \"" . $friend . "\";\n\$friend_chat_db" . $friendcount . " = \"" . $user . $friend . "\";?>");
|
||||
file_put_contents("ssb_db/friends/" . $user . ".count", $friendcount);
|
||||
file_put_contents("ssb_db/friends/" . $friend . ".count", $friendcountFriend);
|
||||
file_put_contents("ssb_db/friends/" . $user . $friend . ".count", "1");
|
||||
file_put_contents("ssb_db/friends/" . $user . $friend . ".php", "<?php \$msg1 = \"" . $user . " and " . $friend . " are now friends!<br />\";?>");
|
||||
}
|
||||
}
|
||||
fclose($handle);
|
||||
} else {
|
||||
echo "ERROR: Friend: " . $friend . " not found in friend pending database.<br />";
|
||||
}
|
||||
}
|
||||
?>
|
133
functions.php
133
functions.php
@ -5,6 +5,8 @@
|
||||
// http://github.com/Pentium44/SSB
|
||||
|
||||
// get filesize for uploaded files
|
||||
session_start();
|
||||
|
||||
function tomb($size, $precision = 2)
|
||||
{
|
||||
$base = log($size) / log(1024);
|
||||
@ -14,7 +16,7 @@ function tomb($size, $precision = 2)
|
||||
}
|
||||
|
||||
function getRandString($n) {
|
||||
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
||||
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_';
|
||||
$randomString = '';
|
||||
|
||||
for ($i = 0; $i < $n; $i++) {
|
||||
@ -33,11 +35,27 @@ function searchForUserTag($str) {
|
||||
}
|
||||
}
|
||||
|
||||
function checkLogin() {
|
||||
$username = $_SESSION['ssb-user'];
|
||||
$passSession = $_SESSION['ssb-pass'];
|
||||
if(!isset($username) || !isset($passSession)) { return false; }
|
||||
include "ssb_db/users/" . $username . ".php";
|
||||
|
||||
if($user_password === $passSession) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function loginForm() {
|
||||
?>
|
||||
<br />
|
||||
<div class="login">
|
||||
<a class="button" href="<?php echo $_SERVER['PHP_SELF']; ?>?forms=register">Register</a>
|
||||
<h3>Login</h3>
|
||||
New to <?php echo $ssbtitle; ?>? No problem,
|
||||
<a href="<?php echo $_SERVER['PHP_SELF']; ?>?forms=register">register</a>
|
||||
here and get started!<br /><br />
|
||||
<form action="<?php echo $_SERVER['PHP_SELF']; ?>?do=login" method="post">
|
||||
<table><tr><td>
|
||||
Username:</td><td> <input class="text" type="text" name="username"></td></tr><tr><td>
|
||||
@ -52,6 +70,7 @@ function changePassForm() {
|
||||
?>
|
||||
<br />
|
||||
<div class="chgpass">
|
||||
<h3>Change password</h3>
|
||||
<form action="<?php echo $_SERVER['PHP_SELF']; ?>?do=changepass" method="post">
|
||||
<table><tr><td>
|
||||
Old password:</td><td> <input class="text" type="password" name="oldpass"></td></tr><tr><td>
|
||||
@ -64,6 +83,33 @@ function changePassForm() {
|
||||
<?php
|
||||
}
|
||||
|
||||
function getUserCount() {
|
||||
$user_count = "0";
|
||||
foreach(array_reverse(glob("ssb_db/users/*.name")) as $postfile) {
|
||||
$user_count++;
|
||||
}
|
||||
|
||||
echo "$user_count users";
|
||||
}
|
||||
|
||||
function getPostCount() {
|
||||
$post_count = "0";
|
||||
foreach(array_reverse(glob("ssb_db/posts/*.post")) as $postfile) {
|
||||
$post_count++;
|
||||
}
|
||||
|
||||
echo "$post_count posts";
|
||||
}
|
||||
|
||||
function getUploadFileCount() {
|
||||
$file_count = "0";
|
||||
foreach(array_reverse(glob("ssb_db/uploads/*")) as $postfile) {
|
||||
$file_count++;
|
||||
}
|
||||
|
||||
echo "$file_count uploads";
|
||||
}
|
||||
|
||||
function uploadAvatarForm() {
|
||||
?>
|
||||
<br />
|
||||
@ -107,6 +153,7 @@ function registerForm() {
|
||||
?>
|
||||
<br />
|
||||
<div class="login">
|
||||
<h3>Register</h3>
|
||||
<form action="<?php echo $_SERVER['PHP_SELF']; ?>?do=register" method="post">
|
||||
<table><tr><td>
|
||||
Username:</td><td> <input class="text" type="text" name="username"></td></tr><tr><td>
|
||||
@ -127,14 +174,16 @@ function registerForm() {
|
||||
|
||||
function postForm() {
|
||||
print <<<EOD
|
||||
<button onclick="javascript:wrapBBCode('i');">Italic</button>
|
||||
<button onclick="javascript:wrapBBCode('u');">Underline</button>
|
||||
<button onclick="javascript:wrapBBCode('b');">Bold</button>
|
||||
<button onclick="javascript:wrapBBCode('url');">URL</button>
|
||||
<h3>Create a post</h3>
|
||||
<button onclick="javascript:wrapBBCode('i');">Italic</button>
|
||||
<button onclick="javascript:wrapBBCode('u');">Underline</button>
|
||||
<button onclick="javascript:wrapBBCode('b');">Bold</button>
|
||||
<button onclick="javascript:wrapBBCode('url');">URL</button>
|
||||
<button onclick="javascript:wrapBBCode('youtube');">Youtube</button>
|
||||
<form action="?do=post" method="post" enctype="multipart/form-data">
|
||||
<label class="input-upload">
|
||||
<input type="file" name="file[]" id="file" multiple>
|
||||
<i class="fa fa-cloud-upload"></i> Upload image
|
||||
<i class="fa fa-cloud-upload"></i> Upload photo / video
|
||||
</label>
|
||||
<br /><textarea rows="5" cols="60" id="msg" name="body"></textarea><br />
|
||||
<input type="submit" name="post" value="Post">
|
||||
@ -145,9 +194,10 @@ EOD;
|
||||
function replyForm($id, $puser) {
|
||||
?>
|
||||
<button onclick="javascript:wrapBBCode('i');">Italic</button>
|
||||
<button onclick="javascript:wrapBBCode('u');">Underline</button>
|
||||
<button onclick="javascript:wrapBBCode('b');">Bold</button>
|
||||
<button onclick="javascript:wrapBBCode('url');">URL</button>
|
||||
<button onclick="javascript:wrapBBCode('u');">Underline</button>
|
||||
<button onclick="javascript:wrapBBCode('b');">Bold</button>
|
||||
<button onclick="javascript:wrapBBCode('url');">URL</button>
|
||||
<button onclick="javascript:wrapBBCode('youtube');">Youtube</button>
|
||||
<form action="?do=reply&pid=<?php echo $id; ?>&user=<?php echo $puser; ?>" method="post">
|
||||
<textarea rows="7" cols="60" id="msg" name="body"></textarea><br />
|
||||
<input type="submit" name="reply" value="Reply">
|
||||
@ -170,23 +220,22 @@ function cleanForm() {
|
||||
function friendReqForm() {
|
||||
?>
|
||||
|
||||
<h2>Request friendship!</h2>
|
||||
<form action="?do=sendfr" method="post">
|
||||
Username: <input type="text" name="user" id="user"> <br />
|
||||
<input type="submit" name="post" value="Send">
|
||||
</form>
|
||||
<h3>Send a friend request</h3>
|
||||
<form action="?do=sendfr" method="post">
|
||||
Username: <input type="text" name="user" id="user"> <br />
|
||||
<input type="submit" name="post" value="Send">
|
||||
</form>
|
||||
<?php
|
||||
}
|
||||
|
||||
|
||||
function sendFriendRequest($user, $friend) {
|
||||
$friendLocation = "ssb_db/friends/" . $friend . ".pending";
|
||||
$handle = fopen($friendLocation, "r");
|
||||
if ($handle) {
|
||||
while (($line = fgets($handle)) !== false) {
|
||||
if($line == $user) { break; } // request already pending
|
||||
}
|
||||
fclose($handle);
|
||||
$friendLocation = "ssb_db/friends/" . $friend . ".notifications";
|
||||
$friendPending = "ssb_db/friends/" . $friend . ".pending";
|
||||
$handle = file_get_contents($friendLocation);
|
||||
if (strpos($handle, $user) !== FALSE) {
|
||||
echo "Friend request is send already and pending accept!<br />";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// Check if user is itself
|
||||
@ -195,18 +244,24 @@ function sendFriendRequest($user, $friend) {
|
||||
$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); }
|
||||
for($x = 1; $x <= $friendcount; $x++)
|
||||
{
|
||||
if(${"friend" . $x} == $friend) { header("Location: index.php?do=friends"); echo "Already following!"; exit(1); }
|
||||
}
|
||||
|
||||
if(file_exists($friendLocation)) {
|
||||
$pending = file_get_contents("ssb_db/friends/" . $friend . ".pending");
|
||||
file_put_contents("ssb_db/friends/" . $friend . ".pending", $pending . "\n" . $user);
|
||||
$notifications = file_get_contents($friendLocation);
|
||||
file_put_contents("ssb_db/friends/" . $friend . ".notifications", "Friend request from " . $user . "! <a class='button' href='?do=accfr&friend=" . $user . "&user=" . $friend . "'>Accept?</a>" . "\n" . $notifications);
|
||||
} else {
|
||||
file_put_contents("ssb_db/friends/" . $friend . ".pending", $user);
|
||||
file_put_contents("ssb_db/friends/" . $friend . ".notifications", "Friend request from " . $user . "! <a class='button' href='?do=accfr&friend=" . $user . "&user=" . $friend . "'>Accept?</a>");
|
||||
}
|
||||
|
||||
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) {
|
||||
@ -246,14 +301,14 @@ function acceptFriendRequest($user, $friend) {
|
||||
// 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); }
|
||||
}
|
||||
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) {
|
||||
if ($handle) {
|
||||
$xx = 0;
|
||||
while (($line = fgets($handle)) !== false) {
|
||||
if($xx >= "1") {
|
||||
@ -278,10 +333,10 @@ function acceptFriendRequest($user, $friend) {
|
||||
file_put_contents("ssb_db/friends/" . $user . $friend . ".count", "1");
|
||||
file_put_contents("ssb_db/friends/" . $user . $friend . ".php", "<?php \$msg1 = \"" . $user . " and " . $friend . " are now friends!<br />\";?>");
|
||||
}
|
||||
}
|
||||
fclose($handle);
|
||||
} else {
|
||||
echo "ERROR: Friend: " . $friend . " not found in friend pending database.<br />";
|
||||
}
|
||||
}
|
||||
fclose($handle);
|
||||
} else {
|
||||
echo "ERROR: Friend: " . $friend . " not found in friend pending database.<br />";
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
1
ssb_db/friends/Chraas.count
Normal file
1
ssb_db/friends/Chraas.count
Normal file
@ -0,0 +1 @@
|
||||
1
|
1
ssb_db/friends/Chraas.pending
Normal file
1
ssb_db/friends/Chraas.pending
Normal file
@ -0,0 +1 @@
|
||||
Pentium44
|
4
ssb_db/friends/Chraas.php
Normal file
4
ssb_db/friends/Chraas.php
Normal file
@ -0,0 +1,4 @@
|
||||
<?php ?>
|
||||
|
||||
<?php $friend1 = "Pentium44";
|
||||
$friend_chat_db1 = "ChraasPentium44";?>
|
1
ssb_db/friends/ChraasPentium44.count
Normal file
1
ssb_db/friends/ChraasPentium44.count
Normal file
@ -0,0 +1 @@
|
||||
1
|
1
ssb_db/friends/ChraasPentium44.php
Normal file
1
ssb_db/friends/ChraasPentium44.php
Normal file
@ -0,0 +1 @@
|
||||
<?php $msg1 = "Chraas and Pentium44 are now friends!<br />";?>
|
1
ssb_db/friends/Pentium44.count
Normal file
1
ssb_db/friends/Pentium44.count
Normal file
@ -0,0 +1 @@
|
||||
1
|
4
ssb_db/friends/Pentium44.php
Normal file
4
ssb_db/friends/Pentium44.php
Normal file
@ -0,0 +1,4 @@
|
||||
<?php ?>
|
||||
|
||||
<?php $friend1 = "Chraas";
|
||||
$friend_chat_db1 = "ChraasPentium44";?>
|
1
ssb_db/users/Chraas.name
Normal file
1
ssb_db/users/Chraas.name
Normal file
@ -0,0 +1 @@
|
||||
Chraas
|
5
ssb_db/users/Chraas.php
Normal file
5
ssb_db/users/Chraas.php
Normal file
@ -0,0 +1,5 @@
|
||||
<?php
|
||||
$accttype = "private";
|
||||
$user_password = "4ea3488c4c0598f6fe74801098123f2e61d88b0f";
|
||||
$user_color = "ededed"; $user_fullname = "Chris Dorman"; $user_avatar = "../../data/defaultprofile.png";
|
||||
?>
|
1
ssb_db/users/Chraas.postnumber
Normal file
1
ssb_db/users/Chraas.postnumber
Normal file
@ -0,0 +1 @@
|
||||
0
|
1
ssb_db/users/Pentium44.name
Normal file
1
ssb_db/users/Pentium44.name
Normal file
@ -0,0 +1 @@
|
||||
Pentium44
|
5
ssb_db/users/Pentium44.php
Normal file
5
ssb_db/users/Pentium44.php
Normal file
@ -0,0 +1,5 @@
|
||||
<?php
|
||||
$accttype = "private";
|
||||
$user_password = "4ea3488c4c0598f6fe74801098123f2e61d88b0f";
|
||||
$user_color = "ededed"; $user_fullname = "Chris Dorman"; $user_avatar = "../../data/defaultprofile.png";
|
||||
?>
|
1
ssb_db/users/Pentium44.postnumber
Normal file
1
ssb_db/users/Pentium44.postnumber
Normal file
@ -0,0 +1 @@
|
||||
0
|
135
style.css
135
style.css
@ -1,4 +1,61 @@
|
||||
@import url('https://fonts.googleapis.com/css2?family=Roboto&family=Ubuntu&display=swap');
|
||||
|
||||
@media only screen and (min-width: 2001px) {
|
||||
.maincontain { max-width: 1180px; }
|
||||
.contain { width: 1000px; }
|
||||
#msgs { width: 960px; }
|
||||
#navcontainer { width: 170px; }
|
||||
}
|
||||
|
||||
@media only screen and (max-width: 2000px) {
|
||||
.maincontain { max-width: 1180px; }
|
||||
.contain { width: 1000px; }
|
||||
#msgs { width: 960px; }
|
||||
#navcontainer { width: 170px; }
|
||||
}
|
||||
|
||||
@media only screen and (max-width: 1400px) {
|
||||
.maincontain { max-width: 1180px; }
|
||||
.contain { width: 1000px; }
|
||||
#msgs { width: 960px; }
|
||||
#navcontainer { width: 170px; }
|
||||
}
|
||||
|
||||
@media only screen and (max-width: 1200px) {
|
||||
.maincontain { max-width: 980px; }
|
||||
.contain { width: 800px; }
|
||||
#msgs { width: 740px; }
|
||||
#navcontainer { width: 170px; }
|
||||
}
|
||||
|
||||
@media only screen and (max-width: 1000px) {
|
||||
.maincontain { max-width: 830px; }
|
||||
.contain { width: 650px; }
|
||||
#msgs { width: 610px; }
|
||||
#navcontainer { width: 170px; }
|
||||
}
|
||||
|
||||
@media only screen and (max-width: 900px) {
|
||||
.maincontain { max-width: 730px; }
|
||||
.contain { width: 550px; }
|
||||
#msgs { width: 510px; }
|
||||
#navcontainer { width: 170px; }
|
||||
}
|
||||
|
||||
@media only screen and (max-width: 800px) {
|
||||
.maincontain { max-width: 630px; }
|
||||
.contain { width: 460px; }
|
||||
#msgs { width: 410px; }
|
||||
#navcontainer { width: 160px; }
|
||||
}
|
||||
|
||||
@media only screen and (max-width: 700px) {
|
||||
.maincontain { max-width: 530px; }
|
||||
.contain { width: 360px; }
|
||||
#msgs { width: 340px; }
|
||||
#navcontainer { width: 160px; }
|
||||
}
|
||||
|
||||
html, body {
|
||||
background-color: #d5d5d5;
|
||||
background-repeat: no-repeat;
|
||||
@ -10,6 +67,7 @@ html, body {
|
||||
font-size: 18px;
|
||||
font-family: "Ubuntu", "Roboto", sans-serif;
|
||||
padding-bottom: 40px;
|
||||
padding-top: 15px;
|
||||
}
|
||||
|
||||
p {
|
||||
@ -21,15 +79,15 @@ h1 {
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-size: 32px;
|
||||
font-size: 30px;
|
||||
}
|
||||
|
||||
h3 {
|
||||
font-size: 26px;
|
||||
font-size: 22px;
|
||||
}
|
||||
|
||||
h4 {
|
||||
font-size: 22px;
|
||||
font-size: 20px;
|
||||
}
|
||||
|
||||
.title {
|
||||
@ -48,46 +106,51 @@ h4 {
|
||||
margin: 0 auto;
|
||||
/*width: 100%;*/
|
||||
/*background-color: #ffffff;*/
|
||||
top: 1px;
|
||||
left: 1px;
|
||||
padding-bottom: 0px;
|
||||
padding: 2px;
|
||||
padding-top: 4px;
|
||||
}
|
||||
|
||||
#navcontainer {
|
||||
width: 702px;
|
||||
max-width: 702px;
|
||||
min-width: 702px;
|
||||
margin: 0 auto;
|
||||
background-color: #ffffff;
|
||||
background-color: #252525;
|
||||
box-shadow: inset -20px -20px 20px -10px #121212;
|
||||
border-radius: 8px 0 0 0;
|
||||
padding-bottom: 20px;
|
||||
}
|
||||
|
||||
#navbar a {
|
||||
text-decoration: none;
|
||||
text-decoration: underline;
|
||||
font-family: "Ubuntu", "Roboto", sans-serif;
|
||||
font-size: 32px;
|
||||
text-align: center;
|
||||
padding-top: 4px;
|
||||
padding-bottom: 5px;
|
||||
background-color: #ffffff;
|
||||
font-size: 14px;
|
||||
padding-top: 1px;
|
||||
padding-bottom: 1px;
|
||||
color: #5577ff;
|
||||
width: 125px;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
#navbar a:hover {
|
||||
background-color: #999999;
|
||||
color: #323232;
|
||||
text-decoration: none;
|
||||
color: #99aaff;
|
||||
}
|
||||
|
||||
#footer {
|
||||
background-color: #121212;
|
||||
border-radius: 0 0 8px 8px;
|
||||
padding-top: 2px;
|
||||
padding-bottom: 2px;
|
||||
text-align: center;
|
||||
color: #dddddd;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.notifications {
|
||||
background-color: #171717;
|
||||
border-radius: 4px;
|
||||
border: solid 1px #222222;
|
||||
padding: 4px;
|
||||
font-size: 14px;
|
||||
padding: 0px;
|
||||
margin: 0;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
|
||||
table { padding: 1px; }
|
||||
tr, td { padding: 2px; }
|
||||
#containtable { padding: 0px; margin: 0; border-collapse: collapse; }
|
||||
#containtable tr, td { padding: 0px; margin: 0; vertical-align: top; }
|
||||
|
||||
textarea {
|
||||
background-color: #222222;
|
||||
@ -132,11 +195,10 @@ input, button, select, label {
|
||||
border: solid 1px #323232;
|
||||
text-align: center;
|
||||
outline: none;
|
||||
font-size: 18px;
|
||||
border-radius: 6px;
|
||||
border-radius: 4px;
|
||||
color: #d7d7d7;
|
||||
margin: auto;
|
||||
padding: 4px;
|
||||
padding: 3px;
|
||||
display: inline-flex;
|
||||
cursor: pointer;
|
||||
}
|
||||
@ -183,10 +245,9 @@ input, button, select, label {
|
||||
padding: 6px;
|
||||
border-radius: 5px 11px 11px;
|
||||
background-color: #2255ff;
|
||||
border: solid 1px #1865ff;
|
||||
margin: 2px;
|
||||
color: #ffffff;
|
||||
overflow-wrap: break-word;
|
||||
max-width: 520px;
|
||||
}
|
||||
|
||||
#msgs {
|
||||
@ -195,15 +256,12 @@ input, button, select, label {
|
||||
border: solid 1px #323232;
|
||||
padding: 6px;
|
||||
height: 400px;
|
||||
width: 578px;
|
||||
margin: auto;
|
||||
font-size: 16px;
|
||||
overflow-y: scroll;
|
||||
}
|
||||
|
||||
.replycontain {
|
||||
margin: 0 auto;
|
||||
width: 600px;
|
||||
}
|
||||
|
||||
.attachment {
|
||||
@ -288,12 +346,9 @@ a:hover {
|
||||
}
|
||||
.contain {
|
||||
background-color: #121212;
|
||||
border: solid 1px #565656;
|
||||
width: 690px;
|
||||
max-width: 690px;
|
||||
min-width: 690px;
|
||||
margin: 0 auto;
|
||||
padding: 5px;
|
||||
border-radius: 0 8px 0 0;
|
||||
}
|
||||
|
||||
.friendslist {
|
||||
@ -314,5 +369,7 @@ a:hover {
|
||||
|
||||
.maincontain {
|
||||
margin: 0 auto;
|
||||
width: 702px;
|
||||
border: solid 1px #343434;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0px 0px 15px 5px #121212;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user