Homebrew RELEASE PHPinfoil, single php file to host your own game for Tinfoil or DBI, no GDrive support, no Database

TheyKilledKenny

Well-Known Member
OP
Member
Joined
Dec 5, 2015
Messages
115
Trophies
0
XP
801
Country
Italy
PHPinfoil
Simple PHP, one file, no database, no external library and no bullshit to serve your backups and eshop games to Tinfoil and DBI

Check it here:
https://github.com/TheyKilledKenny/PHPinfoil/

I wanted to connect my HDD with my nsp to the Switch without the need for cables and I also wanted to reach my collection from anywhere.
I then took a Raspberry to which I connected my usb HDD, and with this php I solved my problems.
Works also on PC Windows/Linux/MacOs with PHP 5 or above, on Nas with php support and in many other place

Why another php to serve index to Tinfoil or DBI?
I needed a light, portable and fast php to create a repository for Tinfoil so that I could install backups without cables.
I also didn't have any need to link to external GDrives or similar.
The projects I found, however, were not able to manage a nested folder structure, which for some repositories can also be articulated and some of them required the use of a DB that I did not want to use.

If you want to use GDrive or others, please check other more feature rich projets like https://github.com/ibnux/php-tinfoil-server

What it does
  • Cycles through all the files and folders in the given path and creates the json file to be provided to Tinfoil
  • The first run it creates a json index cache file (write permission is needed), to avoid rescan all the files. The following times if the cache file exists this is provided, otherwise a new file is created
  • Call the PHPinfoil.php with ?reset to delete and recreate the cache file
  • No Database Needed
How To Use:
  • Put all your games in a folder under the path served by your php webserver, they can be divided into subfolders
  • Copy the PHPinfoil.php file to a folder (also the same folder of games) on the same http server, reachable by http clients
  • Check that all your games have [TitleID] in the filename or Tinfoil won't show it in the list
  • Configure the parameters in PHPinfoil.php accordingly to your setup

Parameters:
At the beginning of the PHP file you will find some options to set for your setup
PHP:
//http Document root, This should be ok as is
$rootFolder = $_SERVER['DOCUMENT_ROOT'] . "/";

//folder where the nsp files are stored
$Folder = "games";

//Writable folder to hold the cache file
$cacheFolder = "cache/";

//Cache file name
$cacheFile = "mycache";

//Extentions to check
$arrExtensions = ['nsp','xci','nsz','xcz'];

// false = json output for Tinfoil, true = html output for Tinfoil and DBI
$DBI = true;



(the belows are quick examples, not intended for production environments)
Setup a Raspberry Pi and a USB HDD (with your backups) as personal shop:
  1. Follow this link to setup a nginx webserver and php: https://www.raspberrypi.org/documentation/remote-access/web-server/nginx.md
  2. Connect the usb hdd, open a terminal on your raspberry pi
  3. type sudo fdisk -l and find /dev/sdx that match your usb drive
  4. type sudo ls -l /dev/disk/by-uuid/ and find UUID related to your /dev/sdx usb drive (Needed in step 6)
  5. type sudo mkdir /var/www/html/php and copy in this PHPinfoil.php renamed in index.php
  6. type sudo mkdir /var/www/html/cache and sudo chmod 777 /var/www/html/cache
  7. type sudo mkdir /var/www/html/games to create a folder where to mount the usb drive
  8. type sudo nano /etc/fstab and add this line at the end UUID=uuid_Found_In_Step2 /var/www/html/games auto uid=pi,gid=pi 0 0
  9. Reboot
  10. enter the address http://rpi.address.ip/php/ in Tinfoil as a new location or open in a web browser to check the resulting json.


From your PC Windows, Linux and should work also on MacOs
  1. Install PHP 5 or greater for your system from https://www.php.net/downloads
  2. copy PHPinfoil.php in the folder where you store your games and rename it in index.php
  3. open terminal/cmd/bash/whatever
  4. type ipconfig or ifconfig command to get your current ip address
  5. cd into your game folder
  6. type php -S 0.0.0.0:80 to start php webserver
  7. set in Tinfoil a location to http://yourIp.at.step.4/
  8. close and reopen Tinfoil
 
Last edited by TheyKilledKenny,

TheyKilledKenny

Well-Known Member
OP
Member
Joined
Dec 5, 2015
Messages
115
Trophies
0
XP
801
Country
Italy
New release is out.

Added a bit of CSS and html to have a more readable file list in case you want to check your list using a standard web browser.
Added new parameter for Back Color ($BackColor), Text Color ($ForeColor) and File list alternate row color ($AltRowColor)
Added asort to sort the Files array

Rember: to recreate the chached file call PHPinfoil.php?reset

Ciao!
 
Last edited by TheyKilledKenny,

arabtm

Well-Known Member
Member
Joined
Feb 1, 2007
Messages
161
Trophies
1
XP
1,514
Country
Indonesia
Hi. I get error when using try to install with DBI:

Invalid request (Malformed HTTP request).

I can get the list of NSPs, but I cannot install any of it.
any idea what I should do?

in DBI config, I use this:
; Network install sources
[Network sources]
; <display name>=<type>|<URL>
Home server=ApacheHTTP|http://192.168.0.189/

is it because ApacheHTTP type? should I use different type? although I don't know what other type for DBI config.

additionally, in unrelated case, I have this message if I open my server locally:
Deprecated: Required parameter $host follows optional parameter $directory in D:\VideoGames\Switch\Games\index.php on line 188
 
Last edited by arabtm,

TheyKilledKenny

Well-Known Member
OP
Member
Joined
Dec 5, 2015
Messages
115
Trophies
0
XP
801
Country
Italy
Hi. I get error when using try to install with DBI:

Invalid request (Malformed HTTP request).

I can get the list of NSPs, but I cannot install any of it.
any idea what I should do?

in DBI config, I use this:
; Network install sources
[Network sources]
; <display name>=<type>|<URL>
Home server=ApacheHTTP|http://192.168.0.189/

is it because ApacheHTTP type? should I use different type? although I don't know what other type for DBI config.

additionally, in unrelated case, I have this message if I open my server locally:
Deprecated: Required parameter $host follows optional parameter $directory in D:\VideoGames\Switch\Games\index.php on line 188
The file download does not go through this php, but is requested directly to the web server, so it should depend on the Apache settings, which unfortunately I know very little about it.

To do a test try to use in DBI a source as
Home server = ApacheHTTP | http: //192.168.0.189/foldername

where foldername is the folder where the nsp file resides.
The Apache directory indexing must be enabled to work, to do it add the Options +Indexes directive to the .htaccess file or apache2.conf or httpd.conf file

Code:
<Directory /files>
   Options Indexes FollowSymLinks MultiViews
   AllowOverride None
   Require all granted
</Directory>

and check if you can install the file in dbi.

Ciao.
 
Last edited by TheyKilledKenny,
  • Like
Reactions: arabtm

arabtm

Well-Known Member
Member
Joined
Feb 1, 2007
Messages
161
Trophies
1
XP
1,514
Country
Indonesia
ah, so I should still set up apache server and this script is basically for the file indexing. got it!
sorry, I'm still new with setting up server, so it was not clear for me about this script. thanks again for the explanation! :)
I'll try again.
 

arabtm

Well-Known Member
Member
Joined
Feb 1, 2007
Messages
161
Trophies
1
XP
1,514
Country
Indonesia
ah, so I should still set up apache server and this script is basically for the file indexing. got it!
sorry, I'm still new with setting up server, so it was not clear for me about this script. thanks again for the explanation! :)
I'll try again.
 

blackbrew

Well-Known Member
Newcomer
Joined
Oct 20, 2008
Messages
79
Trophies
1
Website
abc.moc
XP
228
Country
Netherlands
I followed your simple steps with one deference that my game files are stored on network share mounted to the directory of the Apache server, i also configure tinfoil to see my local server with no problems.

however i got an error when trying to install any nsp file.. when i open http://myserverip/php in web browser i can see all the titlesi have but clicking on any one of them immediately respond with 404 not found.
i can download the files from the browser using the url http://myserverip/gamefoder/file.nsp



any ideas ?
 

Vamidi16

New Member
Newbie
Joined
Feb 9, 2022
Messages
1
Trophies
0
Age
31
Location
TBA
XP
74
Country
Netherlands
I followed your simple steps with one deference that my game files are stored on network share mounted to the directory of the Apache server, i also configure tinfoil to see my local server with no problems.

however i got an error when trying to install any nsp file.. when i open [YOURSERVER] in web browser i can see all the titlesi have but clicking on any one of them immediately respond with 404 not found.
i can download the files from the browser using the url [YOURSERVER_FOLDER_FILE_NSP]



any ideas ?
Can you hover over the games in the web browser and see where the links go to? I have set up the RPI, and web server and mounted a NAS to it. Everything seems to work, so it might be that the URLs are off.

If you already fixed it, may I ask what you did to solve it? Might be helpful in the future or for other people.
 

Delco6714

Member
Newcomer
Joined
Mar 20, 2022
Messages
8
Trophies
0
Age
36
Location
USA
XP
139
Country
United States
I followed your simple steps with one deference that my game files are stored on network share mounted to the directory of the Apache server, i also configure tinfoil to see my local server with no problems.

however i got an error when trying to install any nsp file.. when i open http://myserverip/php in web browser i can see all the titlesi have but clicking on any one of them immediately respond with 404 not found.
i can download the files from the browser using the url http://myserverip/gamefoder/file.nsp



any ideas ?
I noticed when using a Windows host the paths were created wrong but were correct when using a Linux host.
Check your cache file to make sure the pathways are using "/" instead of "\".
 

blackbrew

Well-Known Member
Newcomer
Joined
Oct 20, 2008
Messages
79
Trophies
1
Website
abc.moc
XP
228
Country
Netherlands
Can you hover over the games in the web browser and see where the links go to? I have set up the RPI, and web server and mounted a NAS to it. Everything seems to work, so it might be that the URLs are off.

If you already fixed it, may I ask what you did to solve it? Might be helpful in the future or for other people.
i ditched the whole web server idea and replace it with a direct SMB share from my NAS storage and it works fine.


I noticed when using a Windows host the paths were created wrong but were correct when using a Linux host.
Check your cache file to make sure the pathways are using "/" instead of "\".

I was on ubuntu server installed on a RASPI, all path were correct.
 
Last edited by blackbrew,
  • Like
Reactions: Vamidi16

GregNL

Member
Newcomer
Joined
Jun 30, 2022
Messages
17
Trophies
0
Age
47
Location
Amsterdam
XP
60
Country
Netherlands
Really great. Thanks man! Very useful.
I have a question though. The .json seems o.k. , but in Tinfoil I only get my welcome message, then a blank/empty listing.
My files have the right permissions.
I tried putting more details in this post, but since I'm a new user, not much is allowed.
I could use some help... Thanks in advance.

O.k... changing DBI = true in my config seems to have done the trick. I can see the listing in Tinfoil now :)
Though all GAMES, DLC and UPDATES are in the same, one long list and 0,0B, the list says.. Is that supposed to be like this?
 
Last edited by GregNL,

TheyKilledKenny

Well-Known Member
OP
Member
Joined
Dec 5, 2015
Messages
115
Trophies
0
XP
801
Country
Italy
thaks for this great job
can any one help me putting nsp thumbnail on tinfoil ,
For the thumbnails in Tinfoil you need to write the title id enclosed in square bracket in filename.
Tinfoil should recognise it and show the thumbnails, but you need to have internet connection on, at least the first time.

There are some project out that can rename the nsp files with correct titleid, version, etc.
One is Switch Library Manager, but I don't know if it is currently mantained.

Ciao.
 
  • Like
Reactions: binkinator

DPyro

Well-Known Member
Member
Joined
Oct 17, 2008
Messages
367
Trophies
1
XP
820
Country
Canada
I used PHP on windows with command php -S ip : port and get malformed error when using DBI. I noticed the url is displaying backslash instead of forward slash when viewed in browser. How can I fix this? Listing working but can't download through home server.
 

binkinator

Garfield’s Fitness Coach
Member
GBAtemp Patron
Joined
Mar 29, 2021
Messages
6,511
Trophies
2
XP
6,148
Country
United States
I used PHP on windows with command php -S ip : port and get malformed error when using DBI. I noticed the url is displaying backslash instead of forward slash when viewed in browser. How can I fix this? Listing working but can't download through home server.

Do you mean like this?

https://github.com/TheyKilledKenny/PHPinfoil/issues/2

I believe the Docker version works out of the box. Might want to try it that way.
 
Last edited by binkinator,

GregNL

Member
Newcomer
Joined
Jun 30, 2022
Messages
17
Trophies
0
Age
47
Location
Amsterdam
XP
60
Country
Netherlands
I'm still using and enjoying this, though all files are still listed as filesize 0,0B in Tinfoil. When viewing the listing in my browser all filesizes do show up as they should, so I suppose it's something in Tinfoil, or my PHPinfoil settings?
Does anyone have any idea how to fix this, so the correct filesizes are shown in the listing in Tinfoil? Thanks in advance!
 

DavidChanVN

New Member
Newbie
Joined
Jul 27, 2023
Messages
1
Trophies
0
Age
39
XP
13
Country
Vietnam
hello, can anyone help?

when I set $DBI = true, tinfoil will list the games list, but there's no Welcome message, when I set DBI = false, the cache file become JSON, but not work on Tinfoil, only Welcome message.
Post automatically merged:

hello, can anyone help?

when I set $DBI = true, tinfoil will list the games list, but there's no Welcome message, when I set DBI = false, the cache file become JSON, but not work on Tinfoil, only Welcome message.
 

MysticPrysm

New Member
Newbie
Joined
Nov 8, 2023
Messages
1
Trophies
0
Age
29
XP
12
Country
United States
Anyone here able to help me get this setup please? I'm just inexperienced with anything involving php and the likes.
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • No one is chatting at the moment.
    K3Nv2 @ K3Nv2: Sorry for accidentally bending over