GithubHelp home page GithubHelp logo

php_filehost's Introduction

Simple File Uploader

Simple File Uploader is a script, mainly for sharing random files with people using ShareX. It was mainly developed by @Rouji.

Puts a file sent via POST into a configured directory with a randomised filename but preserving the original filename and file extension, and returns a link to it. Actually serving the file to people is left to nginx to figure out.

Installation

In this installation I assume that a working lemp server is already running (but MySQL/MariaDB is actually not needed).
Firstly create a directory like /var/www/share and unpack all PHP scripts into it. After that, change the owner to www-data respectively nginx.
Dont forget to add read and write permissions to the data/ folder!

Install php7.2-sqlite3 and restart php-fpm. Before continuing setup your nginx config.

Create a new Github OAuth Application and set the Authorization callback URL to https://share.example.com/ if you want to use a subdomain else https://example.com/share/.
In the config.php set $ALLOW_REGISTER = true;, save and press the login button on your site. After a successfull login open config.php again and undo the change by setting $ALLOW_REGISTER = false;.

Perfect you are ready.

NGINX Config

If you want to use this script via a subdomain like share.example.com you should use the following server configuration. Dont forget to use HTTPS, as you have a login on the website!

server {
    listen 80 default_server;
    listen [::]:80 default_server;
    server_name share.example.com;
    return 302 https://$host$request_uri;
}

server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;

    root /var/www/share/;
    index index.php index.html index.htm;
    server_name share.example.com;

    ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;

    add_header Strict-Transport-Security "max-age=31536000;" always;

    location / {
        location ~ /database.db {
                deny all;
        }
        if (-f $request_filename) {
            break;
        }
        rewrite ^/$ /index.php last;
        rewrite ^/(.*) /index.php?file=$1;
    }

    location ~ \.php$ {
            try_files $uri =404;
            fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include fastcgi_params;
    }
}

If you are using the script in a subdirectory like example.com/share/ use the following location directive for your server.

location /share/ {
    location ~ /database.db {

        deny all;
    }
    if (-f $request_filename) {

        break;
    }
    rewrite ^/share/$ /share/index.php last;
    rewrite ^/share/(.*) /share/index.php?file=$1;
}

php_filehost's People

Contributors

gurkengewuerz avatar rj48 avatar rouji avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

php_filehost's Issues

Why delete history?

Hi! I've only just discovered this repo.
Why did you completely delete my commit history?
My project didn't have a license for a long time (it does now), which made forking a bit questionable in any case, but I don't mind that aspect that much.
What I find weird is that you've even linked my repo in the readme... So why rewrite history so I'm not in it? Big chunks of code are clearly still one-to-one verbatim my code.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.