jagenjo / litefilesystem.js

Library with client (js) and serverside (php) to have a filesystem with previews, quotas, metadata, and multiple users with privileges.
MIT License
147 stars 49 forks source link

install.php doesn't create admin user #13

Closed FlachyJoe closed 3 years ago

FlachyJoe commented 3 years ago

Hi, I follow the install guide with Ubuntu 21.04 and get no user in database. NB : tables are created so database connection is ok.

console:

florian@localhost:/var/www/webglstudio/fileserver/src$ sudo -u www-data php install.php force
 + config.php found, testing database connection
PHP Notice:  Undefined index: folder in /var/www/webglstudio/fileserver/src/include/modules/files.php on line 26
 + Database connection established
 + Creating databases and folders
You are about to erase all the data and files inside LFS.
If you are sure type 'YES': YES
 - Database restart in course.
 LOG: Restarting system
 LOG: Removing files folders
 LOG: Droping old tables
 LOG: Creating files tables
 LOG: Units table created
 LOG: Privileges table created
 LOG: Files table created
 LOG: Comments table created
 LOG: Files folder created
 LOG: Drop old tables
 LOG: Creating users tables
 LOG: Users table created
 LOG: Users sessions table created
 LOG: Password recovery table created
 LOG: Creating default users
 LOG:  + Inserting user in db: admin
 LOG: Creating unit for user: 1
 LOG: Error, unit not created
 LOG: System restarted
 + LiteFileServer installed, you can go to the main page.
 - Code: 8 "Undefined index: folder" File: /var/www/webglstudio/fileserver/src/include/modules/files.php Ln: 26
florian@localhost:/var/www/webglstudio/fileserver/src$ ls -l
total 108
-rwxrwxr-x 1 florian  www-data  4983 juin   2 22:03 backup.php
drwxrwxr-x 2 florian  www-data  4096 juin   3 09:01 css
drwxrwxr-x 2 www-data www-data  4096 juin   3 09:41 files
drwxrwxr-x 2 florian  www-data  4096 juin   3 09:01 fonts
drwxrwxr-x 4 florian  www-data  4096 juin   3 09:41 include
-rwxrwxr-x 1 florian  www-data 30423 juin   3 09:27 index.html
-rwxrwxr-x 1 florian  www-data  6814 juin   3 09:33 install.php
drwxrwxr-x 3 florian  www-data  4096 juin   3 09:27 js
-rwxrwxr-x 1 florian  www-data 35687 juin   2 22:03 litefileserver.js
-rwxrwxr-x 1 florian  www-data  1077 juin   2 22:03 server.php
florian@localhost:/var/www/webglstudio/fileserver/src$ mysql -u florian -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 197
Server version: 8.0.25-0ubuntu0.21.04.1 (Ubuntu)

Copyright (c) 2000, 2021, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> USE webglstudio
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> SELECT * FROM lfs_users;
Empty set (0,00 sec)

config.php


<?php

//Site info *************************
define('HOST_URL','localhost');
define('MAIL_ADDRESS','florian@mail.fr');

// SQL database *********************
define('DB_NAME', 'webglstudio'); //your database name
define('DB_USER', 'florian'); //your database user
define('DB_PASSWORD', 'monmotdepasse'); //your database password
define('DB_HOST', 'localhost'); //your database host

define('DB_PREFIX', 'lfs_');
define('DB_REDIS', false ); //use redis database (mostly for sessions), otherwise it will use SQL

//System ****************************
define('ADMIN_PASS','tototo'); //CHANGE THIS
define('ADMIN_MAIL','florian@mail.fr''); //CHANGE THIS
define('GLOBAL_PASS_SALT','pepper salt and other herbs and spam'); //ENTER SOMETHING RANDOM HERE
define('UNITNAME_SALT','sausages bacon and spam and spam'); //ENTER SOMETHING RANDOM HERE

//Config *************************
define('BACKUPS_FOLDER', '../backup' ); //folder to store the backups
define('ALLOW_WEB_REGISTRATION', true ); //allow people to create users
define('ALLOW_BIG_FILES', true ); //allow big files to be uploaded by parts
define('VALIDATE_ACCOUNTS', false ); //force people to validate the account once created
define('FILES_PATH','files/');  //folder where all the files will be stored
define('PREVIEW_PREFIX','_th_'); //prefix added to the filename to designate a preview of a file
define('PREVIEW_SUFIX','.jpg');  //sufix added to the filename of every preview
define('USE_EXTENSIONS_WHITELIST',true); //in case you want to accept only some type of files
define('EXTENSIONS_WHITELIST','png,jpg,jpeg,bmp,txt,json,js,css,html,htm,ttf,otf,webm,wav');
define('USE_EXTENSIONS_BLACKLIST',true); //in case you want to ban some type of files
define('EXTENSIONS_BLACKLIST','exe,o,dll,php,py,rb,app,apk,bat,cmd,com,inx,ipa,isu,job,lnk,msc,msi,msp,mst,osx,out,paf,pif,reg,run,rgs,sct,shb,shs,u3p,vb,vbe,vbs,ws,wsf');
define('VALID_EXTENSIONS','png,jpg,jpeg,bmp,txt,json,js,css,html,htm,ttf,otf,wbin,dae');
define('MAX_USERS_PER_UNIT', 1000);
define('MAX_UNITS_PER_USER', 10);
define('DEFAULT_USER_SPACE', 10 ); //in MBs, (TODO: if 0 no limit)
define('DEFAULT_UNIT_SIZE', (10*1024*1024) ); //in bytes
define('UNIT_MIN_SIZE', 1048576); //in bytes
define('UNIT_MAX_SIZE', 509715200); //in bytes
define('PREVIEW_IMAGE_SIZE', 128); //in pixels
define('MAX_PREVIEW_FILE_SIZE', 300000);//in bytes
define('ALLOW_REMOTE_FILE_DOWNLOADING', false );  //allows to upload files that are not in this server
define('ALLOW_REMOTE_FILES', false); //allow to download remote files

//used to rename categories by file type
$categories_by_type = [ "image/jpeg" => "Image", "image/jpg" => "Image", "image/png" => "Image", "image/webp" => "Image", "audio/wav" => "Audio", "audio/ogg" => "Audio", "audio/mp3" => "Audio" ];

?>```
FlachyJoe commented 3 years ago

I get it working. Is localhost not allowed as HOST_URL ?

jagenjo commented 3 years ago

should be allowed

FlachyJoe commented 3 years ago

EDIT : already moved before first message and it doesn't work…

~~I also move the server from /home/user/public_html/ to /var/www/ with same permissions. Apache configuration may cause problems.~~ in /etc/apache2/apache2.conf:

<Directory /var/www/>
        Options Indexes FollowSymLinks
        AllowOverride None
        Require all granted
</Directory>

in /etc/apache2/mods-enabled/userdir.conf:

        <Directory /home/*/public_html>
                AllowOverride FileInfo AuthConfig Limit Indexes
                Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
                Require method GET POST OPTIONS
                php_admin_value engine On
        </Directory>