anyspace icon indicating copy to clipboard operation
anyspace copied to clipboard

Please continue updating this...

Open Qi2nR9uw opened this issue 1 year ago • 18 comments

It seems the project has already gone quiet and I would hate to see that.

One issue I noticed is when changing account settings from public to private for example, it requires you to enter current password, but if you do that while leaving new password boxes empty it will change your account password to literally nothing.

I am also having issues self hosting it. Since their is no index.php in main directory I am having troubles setting it up even if I try to force it to use public directory.

Please improve things, fix bugs, and maybe even make it easier to self host.

Qi2nR9uw avatar Nov 10 '24 08:11 Qi2nR9uw

thank you for your interest. latest commit 2670ef8675f350d225b922552adc6185e2e4209a fixes install script and now creates config.php (webserver user will need appropriate permissions in core directory) from install script. one note when hosting is that i recommend a reverse proxy setup so you have better control over what part of the app is public facing. right now i have a backend webserver hosting the root project directory and then a reverse proxy for only /public. I will make a YouTube video soon.

superswan avatar Nov 11 '24 00:11 superswan

I am still having issues setting this up somehow :(

I gave up trying to use the public folder and tried moving everything in /public folder outside of it into root. Once I did this I saw the install.php page working but when I enter the information I get "Failed to write config file. Please check permissions.".

I tried giving /core full permissions, and even the install.php, surely I'm doing something wrong.

Is there an easy way to set this up, without using /public folder, and getting everything working all at once, without a separate reverse proxy setup?

Qi2nR9uw avatar Nov 11 '24 01:11 Qi2nR9uw

sorry to hear that. you will want to set permissions on the core folder so www-data or nginx user can create files in that folder.

sudo chown -R www-data:www-data /var/www/anyspace/core
sudo chmod -R 775 /var/www/anyspace/core

You can set insecure permissions 777 recursively on anyspace folder if you just want to get it running.

the app is designed to use public folder for extensibility and to separate backend utils and admin panel. it needs to be hosted at root of webserver since the code uses relative paths and the domain name set at install for URLs across the site. i will take some time to set it up on apache and nginx to eliminate reverse proxy or possibly ship a docker container.

what OS and webserver are you using?

you should need able to configure webserver to only serve public url while denying access to other folders. you may lose access to admin panel though.

<VirtualHost *:80>
    ServerName anyspace.local
    DocumentRoot /var/www/anyspace/public

    <Directory /var/www/anyspace/public>
        AllowOverride All
        Require all granted
    </Directory>

    <Directory /var/www/anyspace>
        Order Allow,Deny
        Deny from all
    </Directory>
</VirtualHost>

superswan avatar Nov 11 '24 11:11 superswan

I used this in .htaccess to let me use /public without issues:

RewriteCond %{REQUEST_URI} !^/public/
RewriteRule ^(.*)$ /public/$1 [L]

/core folder also has permissions.

When I fill out correct information in the install.php and click "Install Anyspace" button I get a blank white screen. (doesn't tell me what my admin password is nor does it seem to create one).

Here is the list of tables it creates (I think its missing some):

    bulletincomments
    bulletins
    comments
    favorites
    friends
    groupcomments
    groups
    layoutcomments
    layouts
    messages
    reports

Then if I try to visit the website and ignore the weird install white screen I see this php error inside the "Cool New People" box:

Fatal error: Uncaught PDOException: 
SQLSTATE[42S02]: Base table or view not found: 1146 
Table 'pkrzolvl_watch.users' doesn't exist 
/www/public/index.php:119 

Stack trace: 
#0 /www/public/index.php(119): PDOStatement->execute() 
#1 {main} thrown in /www/public/index.php on line 119

If I force import the anyspace.sql, the error will go away, but still no admin account.

So I try to create a new account and get this error when registering an account:

Fatal error: Uncaught PDOException: 
SQLSTATE[HY000]: General error: 1364 
Field 'lastactive' doesn't have a default value 
in /www/public/register.php:40 

Stack trace: 
#0 /www/public/register.php(40): PDOStatement->execute() 
#1 {main} thrown in /www/public/register.php on line 40

Server information:

Apache
Linux
PHP Version 8.2.24

Its just one error after another :(

Qi2nR9uw avatar Nov 11 '24 18:11 Qi2nR9uw

It appears users and sessions tables weren't created properly. Please try with a fresh database. Do you have any logs from the SQL server? I haven't had a chance to stand this up on a modern server yet. My dev environment is incredibly outdated, may be compatibility issue.

superswan avatar Nov 11 '24 19:11 superswan

This time I am trying to avoid using the install.php. Instead I am importing the anyspace.sql file into phpmyadmin.

When I import it I see these warning logs (many duplicates of these 2):

Warning: #1681 Integer display width is deprecated and will be removed in a future release. 

Warning: #3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. 

I now make sure /core has permissions, I readded to the .htaccess, and filled out/renamed the config.php

Upon loading the website I see php error since I assume admin account creation was skipped:

Warning: Undefined variable $adminUser in /www/core/settings.php on line 15

I now attempt to register an account and get this same error as before:

Fatal error: Uncaught PDOException: 
SQLSTATE[HY000]: General error: 1364 Field 'lastactive' doesn't have a default value 
in /www/public/register.php:40 

Stack trace: 
#0 /www/public/register.php(40): PDOStatement->execute() 
#1 {main} thrown in /www/public/register.php on line 40

Qi2nR9uw avatar Nov 11 '24 20:11 Qi2nR9uw

yeah, admin user wasn't created. if you have working config.php then save this into /public as createAdminUser.php and visit the URL for it in your setup.

<?php
require("../core/config.php");
require("../core/conn.php");
require_once("../lib/password.php");

function generateRandomPassword($length = 8) {
    $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
    $randomPassword = '';
    for ($i = 0, $charactersLength = strlen($characters); $i < $length; $i++) {
        $randomPassword .= $characters[rand(0, $charactersLength - 1)];
    }
    return $randomPassword;
}

try {
    $conn->beginTransaction();

    $adminUsername = "admin"; //<---- Change this
    $adminEmail = "[email protected]"; // <---- Change this 
    $password = generateRandomPassword();
    $hashedPassword = password_hash($password, PASSWORD_DEFAULT);

    $sqlInsertUser = "INSERT INTO `users` (`id`, `rank`, `username`, `email`, `password`, `date`, `bio`, `interests`, `css`, `music`, `pfp`, `currentgroup`, `status`) 
                      VALUES (1, 1, ?, ?, ?, NOW(), '', '', '', 'default.mp3', 'default.jpg', 'None', '');";

    $stmt = $conn->prepare($sqlInsertUser);
    $stmt->execute(array($adminUsername, $adminEmail, $hashedPassword));

    $conn->commit();

    echo "Admin user created successfully!\n";
    echo "Username: " . htmlspecialchars($adminUsername) . "\n";
    echo "Email: " . htmlspecialchars($adminEmail) . "\n";
    echo "Password: " . htmlspecialchars($password) . "\n";
} catch (Exception $e) {
    $conn->rollback();
    echo "Failed to create admin user: " . $e->getMessage();
}
?>

Check your DB if you can and see if you even have sessions and users tables. If not then I recommend running the SQL statements in install.php directly on the sql server rather than importing the .sql file

superswan avatar Nov 11 '24 23:11 superswan

I created the createAdminUser.php and went to the page and got this error (same one when trying to register normal account):

Failed to create admin user: SQLSTATE[HY000]: General error: 1364 Field 'lastactive' doesn't have a default value

I indeed do have sessions and users table (both empty of course).

Qi2nR9uw avatar Nov 11 '24 23:11 Qi2nR9uw

update the create admin script insert statement to set a value for lastactive or set the value to NULL in the database.

i will update the install script to set a default value at the time of install.

$sqlInsertUser = "INSERT INTO `users` (`id`, `rank`, `username`, `email`, `password`, `date`, `lastactive`, `bio`, `interests`, `css`, `music`, `pfp`, `currentgroup`, `status`) 
                  VALUES (1, 1, ?, ?, ?, NOW(), NULL, '', '', '', 'default.mp3', 'default.jpg', 'None', '');";

superswan avatar Nov 12 '24 00:11 superswan

When I try null it says it can't be null :( Failed to create admin user: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'lastactive' cannot be null

I'll need to wait until you can hopefully release a fix.

Qi2nR9uw avatar Nov 12 '24 00:11 Qi2nR9uw

Ok, sorry for all the trouble. Thanks for working through this with me. Latest commit has fixed (again) install script. There is no longer NULL constraint in sessions and users tables. Default values are set when admin user is created.

If you want to try this before starting with fresh DB it's most likely to work.

$sqlInsertUser = "INSERT INTO `users` (`id`, `rank`, `username`, `email`, `password`, `date`, `lastactive`, `bio`, `interests`, `css`, `music`, `pfp`, `currentgroup`, `status`) 
                  VALUES (1, 1, ?, ?, ?, NOW(), NOW(), '', '', '', 'default.mp3', 'default.jpg', 'None', '');";

Or remove NULL constraints on the last* datetime values.

Sorry, kind of rushing trying to get this working for you before I can take some time to setup proper environment and clean up code.

superswan avatar Nov 12 '24 02:11 superswan

Good news, the updated install.php seems to work fine and it got everything setup correctly.

Here are 3 pretty big issues I've ran into so far:

  1. My profile doesn't work, I try to visit it and its just a white screen with nothing else.
  2. The Account Settings has some issues. You can't change Privacy settings without needing to provide your Old Password, but if you type your Old Password it also changes your account password to literally anything that is in the new password textbox even if the boxes are empty.
  3. The Layout textbox on manage.php seems to be required and you can't leave it empty.
  4. When I try to visit the admin panel, I simply get a error 404 page.
  5. When I visit the editstatus.php page I see these errors at the top of the page:
Warning: Trying to access array offset on value of type null in /www/public/editstatus.php on line 31

Warning: Trying to access array offset on value of type null in /www/public/editstatus.php on line 32

Warning: Trying to access array offset on value of type null in /www/public/editstatus.php on line 33
  1. I cannot create a Blog post if it has emoji in it I assume, I get this error: Error: SQLSTATE[HY000]: General error: 1366 Incorrect string value: '\xF0\x9F\x98\xA9Ju...' for column 'text' at row 1

  2. If I try to make a blog post without any emojis in it, I get a different error: Error: SQLSTATE[HY000]: General error: 1364 Field 'privacy_level' doesn't have a default value

  3. Posting a Bulletin also doesn't allow the emoji icons.

  4. Trying to registering a new account gets this error: Fatal error:

Uncaught PDOException: 
SQLSTATE[HY000]: General error: 1364 Field 'css' doesn't have a default value 
in /www/public/register.php:40 

Stack trace: 
#0 /www/public/register.php(40): PDOStatement->execute() 
#1 {main} 
thrown in /www/public/register.php on line 40

These are just some of the quick issues I have found and I'd imagine there are plenty more sadly. Thank you for the help so far though.

Qi2nR9uw avatar Nov 12 '24 03:11 Qi2nR9uw

happy to take a look at these. if @superswan could tell me the features they're working on (as to not duplicate work) I can hopefully get a PR ready by Saturday.

shrapnelnet avatar Dec 25 '24 18:12 shrapnelnet

happy to take a look at these. if @superswan could tell me the features they're working on (as to not duplicate work) I can hopefully get a PR ready by Saturday.

@shrapnelnet i tried reaching out to you on x/twitter, i would like to discuss outside of this issue. it'll make collaboration a little easier.

superswan avatar Dec 29 '24 02:12 superswan

@superswan haven't recieved a message, sorry. my mastodon is listed on my homepage, and I should respond promptly on there. otherwise, I always check my email ([email protected])

shrapnelnet avatar Dec 29 '24 16:12 shrapnelnet

I was able to successfully install on a fresh server with the following specs

------------------------------------
NGINX Version:
nginx version: nginx/1.22.1
------------------------------------
PHP Version:
PHP 8.2.26 (cli) (built: Nov 25 2024 17:21:51) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.2.26, Copyright (c) Zend Technologies
    with Zend OPcache v8.2.26, Copyright (c), by Zend Technologies
------------------------------------
MariaDB/MySQL Version:
mysql  Ver 15.1 Distrib 10.11.6-MariaDB, for debian-linux-gnu (x86_64) using  EditLine wrapper
Database Server Version:
Enter password: 
+---------------------------+
| VERSION()                 |
+---------------------------+
| 10.11.6-MariaDB-0+deb12u1 |
+---------------------------+
------------------------------------
Operating System:
Distributor ID: Debian
Description:    Debian GNU/Linux 12 (bookworm)
Release:        12
Codename:       bookworm
------------------------------------

Commands used to setup database

DROP DATABASE IF EXISTS anyspace;
DROP USER IF EXISTS 'anyspace'@'%';
DROP USER IF EXISTS 'anyspace'@'localhost';

CREATE DATABASE anyspace;

CREATE USER 'anyspace'@'%' IDENTIFIED BY 'securepassword';
CREATE USER 'anyspace'@'localhost' IDENTIFIED BY 'securepassword';

GRANT ALL PRIVILEGES ON anyspace.* TO 'anyspace'@'%';
GRANT ALL PRIVILEGES ON anyspace.* TO 'anyspace'@'localhost';
FLUSH PRIVILEGES;

NGINX config

server {
    listen 80;
    server_name example.com;

    root /opt/devspace/public;
    index index.php index.html;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location ~ \.php$ {
        include fastcgi_params;
        fastcgi_pass unix:/run/php/php8.2-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }

    location ~ /\.(?!well-known).* {
        deny all;
    }

    error_log /var/log/nginx/example.com-error.log;
    access_log /var/log/nginx/example.com-access.log;
}

Tyler and I have connected, and I've found a few other people interested in the project. I will do my best to deliver by the end of the year.

superswan avatar Jan 23 '25 02:01 superswan

I love this project! .. I am so looking forward to when all of the features are added and bugs worked out. Great job so far guys!

alleyvandal avatar Feb 07 '25 16:02 alleyvandal

makes me very happy to hear!

@superswan apologies for lack of communication as of these last few, was prepping for some work stuff but is all done now. will be back at computer Sunday.

if you attach some issues, I'll get to work on them then :)

best wishes, t

shrapnelnet avatar Feb 07 '25 16:02 shrapnelnet