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
113
Trophies
0
XP
771
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
113
Trophies
0
XP
771
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
157
Trophies
0
XP
1,235
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
113
Trophies
0
XP
771
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
157
Trophies
0
XP
1,235
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
157
Trophies
0
XP
1,235
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
0
Website
abc.moc
XP
203
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
30
Location
TBA
XP
39
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
34
Location
USA
XP
108
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
0
Website
abc.moc
XP
203
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,
General chit-chat
Help Users
    DEMONGreninjaPG @ DEMONGreninjaPG: your a rapist kennies