Total Pageviews

Thursday, 16 September 2021

网盘程序Pomf


Pomf is a simple lightweight file host with support for drop, paste, click and API uploading.

Documentation Status

Features

  • One click uploading, no registration required
  • A minimal, modern web interface
  • Drag & Drop & Paste supported
  • Upload API with multiple response choices
    • JSON
    • HTML
    • Text
    • CSV
  • Supports ShareX and other screenshot tools

Demo

See the real world example at demo.pomf.se.

Requirements

Original development environment is Nginx + PHP7.3 + SQLite, but is confirmed to work with Apache 2.4 and newer PHP versions. Should work with any other PDO-compatible database.

Node is used to compile Pomf, after that is runs on PHP.

Installation

Installation and configuration can be found at Pomf Documentation.

If you need a admin panel check out Moe Panel.

File expiration

If you want files to expire please have a look at Uguu instead which is based on Pomf.

Getting help

Hit me up at @nekunekus or email me at neku@pomf.se.

The Pomf community gathers on IRC.

  • IRC (users): #pomfret on Rizon (irc.rizon.net)
from https://github.com/Pomf/Pomf
-----

安装方法:

Requirements

Software

  • Debian 9+
  • Nginx-1.14.2 or newer
  • PHP/PHP-FPM-5.3 or newer (tested with 7.3/8.0)
  • Git
  • SQLite3
  • NodeJS
  • Certbot

Installation

Packages

We will start off by installing the following packages:

apt-get install nginx-full php7.3-fpm php7.3 sqlite3 php7.3-sqlite3 nodejs certbot git

Domain and SSL certificate

You will need a domain for the front page and uploading and a subdomain to serve this files. e.g SuperKawaiiihost.com and a.SuperKawaiiihost.com.

Use Letsencrypt to obain a SSL cert.

Paths

We are assuming you are using the following paths for various things, if they don't exist you should create them.

mkdir /var/www
mkdir /var/www/pomf
mkdir /var/www/pomf/dist
mkdir /var/www/db
mkdir /var/www/files
  • Pomf: /var/www/pomf
  • Pomf compiled: /var/www/pomf/dist
  • Uploaded files: /var/www/files
  • Database: /var/www/db

Download Pomf, setup DB and set permissions

Run this command to clone the Pomf Github and move the files to the correct folders, or do it yourself (I don't care).

cd /var/www/pomf/
git clone https://github.com/pomf/pomf
cd pomf/
mv * ..
cd ..
rm -rf pomf

Now let's setup the database, run this command:

sqlite3 /var/www/db/pomf.sq3 -init /var/www/pomf/sqlite_schema.sql

Then set the correct permissions so Nginx, PHP and SQLite can do their thing.

chown www-data:www-data /var/www/db/pomf.sq3
chown www-data:www-data /var/www/files
chmod 775 /var/www
chmod -R 775 /var/www/

Migrating from MySQL to SQLite (Optional)

Only do this step if you are already running a Pomf instance on MySQL!

Compared to SQLite, MySQL is relatively complicated to administer, brings in many unneeded dependencies, and consumes more resources. Additonally, as a network service, poorly configured installations have the potential to pose a security risk.

For these reasons, you may wish to use SQLite rather than MySQL.

Fortunately, it is incredibly simple to migrate your database. This may be done on a live server, if you desire, and requires zero downtime.

The process described below involves running these commands on a live server. Nothing done here affects your main site, until running the very last command, which is done after verifying there are no issues.

No changes described here are destructive, and are easily reverted. They only have the potential to cause uploading to fail gracefully, and will not affect downloading.

Run the following commands as root, to dump your database, and make a SQLite database with the contents.

mkdir /var/db/pomf
wget -O /tmp/m2s https://github.com/dumblob/mysql2sqlite/raw/master/mysql2sqlite.sh
mysqldump -u OLD_DB_USER -p OLD_DB_PASS pomf | sh /tmp/m2s | sqlite3 /var/db/pomf/sq3
rm /tmp/m2s
chown -R nginx:nginx /var/db/pomf #replace user as appropriate
chmod 0750 /var/db/pomf && chmod 0640 /var/db/pomf/sq3

Edit the file php/includes/settings.inc.php, in your source directory, making the changes outlined below. Note, changing the second two lines is optional, as they are simply ignored when using SQLite.

define('POMF_DB_CONN', '[stuff]'); ---> define('POMF_DB_CONN', 'sqlite:/var/db/pomf/pomf.sq3');
define('POMF_DB_USER', '[stuff]'); ---> define('POMF_DB_USER', null);
define('POMF_DB_PASS', '[stuff]'); ---> define('POMF_DB_PASS', null);

Then, run make DESTDIR=/path/to/main_site/testing_dir (note the testing_dir component) to rebuild the website, and copy it into place, in a new testing subdirectory.

Now, navigate to this subdirectory in your web browser, e.g. http://example.com/testing_dir, and verify that uploading works fine. If so, excellent! You may rerun make DESTDIR=/path/to/main_site to update your main site.

All done! You may disable or uninstall MySQL if you wish.

Nginx example config

I won't cover settings everything up, here are some Nginx examples.

Main domain:

server {

    listen          443 ssl http2;
    server_name   www.yourdomain.com yourdomain.com;

    ssl on;
    ssl_certificate /path/to/fullchain.pem;
    ssl_certificate_key /path/to/privkey.pem;
    ssl_protocols TLSv1.2 TLSv1.3;
    ssl_ciphers 'EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH';
    ssl_ecdh_curve secp384r1;  

    root /path/to/pomf/dist/;
    autoindex   off;
    access_log      off;
    index index.html index.php;  

    location ~* \.(css|js|jpg|jpeg|gif|png|ico|xml|eot|woff|woff2|ttf|svg|otf|x-icon|avif|webp|apng)$ {
    expires 30d;
    }

    gzip on;
    gzip_min_length 1000;
    gzip_comp_level 6;
    gzip_proxied any;
    gzip_types text/css text/js text/javascript application/javascript application/x-javascript;

    location ~* \.php$ {
    fastcgi_pass unix:/var/run/php/php7.3-fpm.sock;
    fastcgi_intercept_errors on;
    fastcgi_index index.php;
    fastcgi_split_path_info ^(.+\.php)(.*)$;
    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }
}

Subdomain serving files (do not enable PHP here):

server {
    listen          443 ssl;
    server_name     www.subdomain.serveryourfiles.com subdomain.serveryourfiles.com;

    ssl on;
    ssl_certificate /path/to/fullchain.pem;
    ssl_certificate_key /path/to/privkey.pem;
    ssl_protocols TLSv1.2 TLSv1.3;
    ssl_ciphers 'EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH';
    ssl_ecdh_curve secp384r1;

    root            /var/www/files/;
    autoindex       off;
    access_log      off;
    index           index.html;
}

To redirect HTTP to HTTPS make a config for each domain like so:

server {
    listen 80;
    server_name www.domain.com domain.com; 
    return 301 https://domain.com$request_uri;
}

If you are running everything from one domain use something like this:

server{

    listen          443 ssl;
    server_name     www.yourdomain.com yourdomain.com;
    ssl on;
    ssl_certificate /path/to/fullchain.pem;
    ssl_certificate_key /path/to/privkey.pem;
    ssl_protocols TLSv1.2 TLSv1.3;
    ssl_ciphers 'EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH';
    ssl_ecdh_curve secp384r1;

    root /var/www/pomf/dist/;
    autoindex       off;
    access_log      off;
    index index.html index.php;

    location ~* \.(css|js|jpg|jpeg|gif|png|ico|xml|eot|woff|woff2|ttf|svg|otf|x-icon|avif|webp|apng)$ {
    expires 30d;
    }

    location ^~ /files/ {
     alias /var/www/files/;
     index index.html index.htm;
     autoindex off;
     include mime.types;
     types {
     text/plain php;
    }
 }
    gzip on;
    gzip_min_length 1000;
    gzip_comp_level 6;
    gzip_proxied any;
    gzip_types text/css text/js text/javascript application/javascript application/x-javascript;

    location ~* \.php$ {
    fastcgi_pass unix:/var/run/php/php7.3-fpm.sock;
    fastcgi_intercept_errors on;
    fastcgi_index index.php;
    fastcgi_split_path_info ^(.+\.php)(.*)$;
    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }
}

Also change client_max_body_size in nginx.conf to the the max file upload size, e.g 128M (128MB).

PHP-FPM Configuration

Edit /etc/php/7.3/fpm/php.ini and change the settings post_max_size and upload_max_filesize to the same value as in Nginx.

No further configuration should be needed for PHP unless you want to enable e.g OPCache. I will not cover that at this time.

Restarting services

Now we just need to restart some services in order to load the new configuration.

service nginx restart
service php7.3-fpm restart

Pomf Configuration and installation

Swig Templates

You may edit the files inside templates/ to your liking.

Don't touch the strings that are formatted like {{example}} or {% extends "example.swig" %} if you want it to pull this from the configuration when you compile.

dist.json

This configuration file contains settings that will be parsed when compiling the site.

/var/www/pomf/dist.json

  • banners the default ones are the malware scans banner and the donation one appearing under the upload button, for starters these are not needed.
  • generateRobotstxt default as false, I'd recommend making your own robots.txt.
  • generateSitemap default as false, set as true for better SEO on e.g Google(?).
  • max_upload_size default is 128, the max file size which an user can upload in MB. Be sure this matches the PHP/Nginx configuration.
  • production default as false, set this to true when you're done tweaking.
  • siteName the name of your site, e.g SuperKawaiiHost. This will appear in the browser title and on several places on the website. If you changed the expire time remember to change that here as well.
  • siteUrl the URL to your site e.g https://SuperKawaiiHost.com
  • abuseContact the email dedicated to receive abuse reports, this can be the same as infoContact if you want. Make sure it's a valid email or else you run the risk of getting into trouble from your server provider.
  • infoContact the email dedicated to receive general email from users.
  • ServerCountryLocation the country your server is located in, this is related to abuse/DMCA since it often depends on local laws.
  • SiteMetaInfo a description of your site, search engines show this data in searches for your site.
  • ToolsDesc some text added to the tools page to inform users about the need to modify the existing tools. You can change this to whatever you want.
  • paypalUrl the URL to your Paypal donation page. This can be ignored if the donations banner isn't enabled, or if you don't want to enable that method of donating.
  • bitcoinAddress your BTC address for donations. This can be ignored if the donations banner isn't enabled. or if you don't want to enable that method of donating.
  • flattrUrl your Flattr donation URL. This can be ignored if the donations banner isn't enabled. or if you don't want to enable that method of donating.

settings.inc.php

This configuration file contains settings that are parsed each time a user uploads a file, if you want to edit them after compiling you will find it in dist/includes/settings.inc.php.

/var/www/pomf/static/php/includes/settings.inc.php

  • POMF_DB_CONN location of your SQLite database, if you are following this guide it should be /var/www/db/pomf.sq3. Change this to mysql:socketetc if you are using MySQL.
  • POMF_DB_USER leave this as NULL if you are using SQLite.
  • POMF_DB_PASS leave this as NULL if you are using SQLite.
  • LOG_IP default is false seeing as Pomf is made to be privacy aware, if you want you can turn this on and the IP of the uploaded file will be stored in the DB.
  • POMF_FILES_ROOT the location where uploaded files are to be stored, change this to /var/www/files/.
  • POMF_FILES_RETRIES maximum number of tries to regenerate filename in case an existing one already exists, this is highly unlikely and even if it does 15 tries is more than enough.
  • POMF_FILES_LENGTH the length of the new filename, default is 8, this can be increased or decreased however setting too low makes it easier to brute force a list of uploaded files or increases the chances of the filename already existing in the DB.
  • POMF_URL the URL of the subdomain serving the uploaded files, e.g https://a.superkawaiihost.com/.
  • ID_CHARSET the characters that will be used to randomly generate a new filename, just leave this as it is.
  • CONFIG_BLOCKED_EXTENSIONS is a list of the blocked file extensions, these can not be uploaded. It's recommended to keep the defaults since they are commonly used by malicious actors to spread malware via file sharing services. You may remove or add extensions to this list.
  • CONFIG_BLOCKED_MIME this is a list of blocked MIME types, a MIME identifies what kind of format a file is since you can save an executable file as a .jpg, it's recommended that blocked extensions match MIME types. You may remove or add MIME types to this list.
  • doubledots this is a list of file extensions which are formatted with 2 dots instead of 1 (like most). I would recommend leaving this as it is.

Compilation

Now we just need to compile the files using our configuration, the output will be in /var/www/pomf/dist/.

Simply run:

cd /var/www/pomf/
make
make install

Finishing up and troubleshooting

Navigate to your domain, if it all looks correct and works it's all good in the hood and you're done.

Blank page or 404/403 error

  • Check permissions, make sure www-data (Nginx) can read the directories and files in /var/www/.
  • Check your Nginx configuration and make sure they are correct.

Compilation errors

  • Did you install nodejs?
  • Check for mistakes in dist.json and the template .swigs like the ones below.

Example 1:

{% extends "layout_index.swig" % 

(missing a "}" at the end)

Example 2:

"paypalUrl": "payshit.die" 

(missing a "," at the end)

Example 3:

"templates/faq.swig",
"templates/tools.swig", <---- Wrong!
],

(there should be no "," when it's the last entry in a list.)

  • If you still can't compile try cloning the repo again and start fresh.
  • Something is wrong with the repo code, please open a issue!

"Server error"

This usually means something is wrong with the configuration, permission or PHP.

  • Check permissions, make sure www-data (Nginx/PHP-FPM) can read/write to the directories and files in /var/www/.
  • Make sure PHP-FPM is working, check the error log /var/log/php7.3-fpm.log.
  • Check includes/settings.inc.php and make sure something isn't misspelled or a ' or ; is missing.

Empty response after uploading

  • Check permissions, make sure www-data (Nginx/PHP-FPM) can read/write to the directories and files in /var/www/.
  • Make sure PHP-FPM is working, check the error log /var/log/php7.3-fpm.log.
  • Check includes/settings.inc.php and make sure something isn't misspelled or a ' or ; is missing.
  • Make sure you created the /var/www/db/pomf.sq3 database and that it is populated.

"Filetype not allowed"

This means the filetype and/or MIME is blocked, check your CONFIG_BLOCKED_EXTENSIONS and CONFIG_BLOCKED_MIME.

"File too big"

This usually means you forgot change the Nginx and/or PHP configuration to allow bigger files, or the file is too big. :)

  • Check /etc/php/7.3/fpm/php.ini for the values post_max_size and upload_max_filesize.
  • Check /etc/nginx/nginx.conf for the value client_max_body_size.
  • Restart the Nginx and PHP-FPM service.

API

To upload using curl or make a tool you can post using:

  • curl -i -F files[]=@yourfile.jpeg https://pomf.se/upload.php (JSON Response)
  • curl -i -F files[]=@yourfile.jpeg https://pomf.se/upload.php?output=text (Text Response)
  • curl -i -F files[]=@yourfile.jpeg https://pomf.se/upload.php?output=csv (CSV Response)
  • curl -i -F files[]=@yourfile.jpeg https://pomf.se/upload.php?output=html (HTML Response)

Getting help

Open a issue if something seems wrong with the code.

Hit me up at @nekunekus or email me at neku@pomf.se.

from https://docs.uguu.se/pomf/

--------------------------------------------

Uguu/Pomf ClonesPlease note that all sites listed below might not share the same codebase as Pomf or Uguu but has the same philsosofy and style.

Uguu.se

100MB file limit, expires after 24 hours.

Pomf Crawler

List of even more Pomf-like sites!

Fileditch.com

15GB file limit.

img.neko.airforce

200MB file limit.

Qu.ax

100MB file limit.

Cockfile.com

2GB file limit, expires after 24 hours.

Catbox.moe

200MB file limit, uses it's own codebase.

safe.fiery.me

25MB file limit.

tmp.ninja

10GB file limit, expires after 48 hours. Uses old Uguu codebase.

pomf.lain.la

512MB file limit.

femto.pw

Uses it's own codebase.

midi.moe

200MB file limit.

sicp.me

114MB file limit.

moepantsu.com

128MB file limit.

i.ceanko.ru

25MB file limit.

trash.network

100MB file limit.

from https://status.uguu.se/clones.html

-----

https://git.fuwafuwa.moe/lesderid/pomf-rehost

--------------------------------------

https://files.catbox.moe/mecnag.png

https://catbox.moe/faq.php says:

'Are you a pomf.se clone?

Yes/No. The site is based around pomf's "simple sharing" aspect, but no code comes from pomf.'

https://catbox.moe的域名注册于2015-04-06  (
https://who.is/whois/catbox.moe),看看这个个人网盘网站能维持多久。

No comments:

Post a Comment