Toggle menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

PHPinfoil Switch: Difference between revisions

From GameBrew
(Created page with "{{Infobox Switch Homebrews |title=PHPinfoil |image=Switch-logo.png |description=Simple PHP to serve your backups and eshop games to Tinfoil and DBI |author=TheyKilledKenny |lastupdated=2021/06/07 |type=PC Utilities |version=0.2 |license=Mixed |download=https://dlhb.gamebrew.org/switchhomebrews/phpinfoilswitch.7z |website=https://gbatemp.net/threads/phpinfoil-single-php-file-to-host-your-own-game-for-tinfoil-or-dbi-no-gdrive-support-no-database.589272/ |source=https://git...")
 
No edit summary
 
(2 intermediate revisions by the same user not shown)
Line 5: Line 5:
|author=TheyKilledKenny
|author=TheyKilledKenny
|lastupdated=2021/06/07
|lastupdated=2021/06/07
|type=PC Utilities
|type=Game Installer Companion
|version=0.2
|version=0.2
|license=Mixed
|license=Mixed
|download=https://dlhb.gamebrew.org/switchhomebrews/phpinfoilswitch.7z
|download=https://dlhb.gamebrew.org/switchhomebrews/phpinfoilnx.7z
|website=https://gbatemp.net/threads/phpinfoil-single-php-file-to-host-your-own-game-for-tinfoil-or-dbi-no-gdrive-support-no-database.589272/
|website=https://gbatemp.net/threads/phpinfoil-single-php-file-to-host-your-own-game-for-tinfoil-or-dbi-no-gdrive-support-no-database.589272/
|source=https://github.com/TheyKilledKenny/PHPinfoil
|source=https://github.com/TheyKilledKenny/PHPinfoil
|donation=
|donation=
}}
}}
{{#seo:
Simple PHP, one file, no database, no external library to serve your backups and eshop games to Tinfoil and DBI.
|title=Switch Homebrew PC Tools (PC Utilities) - GameBrew
 
|title_mode=append
This was intended to be a lightlight, portable and fast PHP solution to create a Tinfoil repository for installing backups without cables. While similar projects exist, they lack the ability to manage a folder structure, which for some archives can also be articulated. 
|image=Switch-logo.png
 
|image_alt=PHPinfoil
Moreover, there was no need to incorporate external services like GDrive or similar platforms. If you want to use GDrive or other external link, please check other more feature rich, projects like [https://github.com/ibnux/php-tinfoil-server PHP Tinfoil Server].
}}
 
{{cleanup|article|Needs cleanup}}
==Features==
Simple PHP to serve your backups and eshop games to Tinfoil and DBI
*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.
 
==User guide==
===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.
 
'''Warning:'''
*Tinfoil needs the TitleId in the file name. To correctly rename and reorganize yor collection you can use:
*[[Switch Library Manager]] by @giwty
*[[Switch Backup Manager]] by @gibaBR
 
===Parameters===
At the beginning of the PHP file you will find some options to set for your setup
 
'''PHP:'''
<pre>
//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;
</pre>
 
'''Example:'''
 
Change the assumptions below to match your case:
*Assuming your http server is serving at http://1.2.3.4:8080/
*Assuming the games are in /data/games folder of your http server. so they can be downloaded from
** <nowiki>http://1.2.3.4:8080/data/games/file[0100AD8015550000].nsp</nowiki>
** or subfolders like
** <nowiki>http://1.2.3.4:8080/data/games/mybackup/file[0100AD8015550000].nsp</nowiki>
*Assuming you put this php file in /php so can be reached at http://1.2.3.4:8080/php/index.php
*Assuming you have write permission on the /cache folder.
*Assuming you want to list nsp, xci, nsz and xcz file types.
 
Set parameters with this values:
  $rootFolder = $_SERVER['DOCUMENT_ROOT'] . "/";
  $Folder = "data/games";
  $cacheFolder = "cache/";
  $cacheFile = "mycache.json";
  $arrExtensions = ['nsp','xci','nsz','xcz'];
in Tinfoil set a location to http://1.2.3.4:8080/php/
 
(the belows are quick examples, not intended for production environment)
 
===Quick examples===
====Setup a Raspberry Pi and a USB HDD as personal shop====
To setup a Raspberry Pi and a USB HDD (with your backups) as personal shop:
#Follow this link to setup a nginx webserver and php: https://www.raspberrypi.org/documentation/remote-access/web-server/nginx.md
#Connect the usb hdd, open a terminal on your raspberry pi.
#Type <code>sudo fdisk -l</code> and find /dev/sdx that match your usb drive.
#Type <code>sudo ls -l /dev/disk/by-uuid/</code> and find UUID related to your /dev/sdx usb drive (Needed in step 6).
#Type <code>sudo mkdir /var/www/html/php</code> and copy this index.php in the folder /var/www/html/php.
#Type <code>sudo mkdir /var/www/html/cache</code> and <code>sudo chmod 777 /var/www/html/cache</code>
#Type <code>sudo mkdir /var/www/html/games</code> to create a folder where to mount the usb drive.
#Type <code>sudo nano /etc/fstab</code> and add this line at the end <code>UUID=uuid_Found_In_Step2 /var/www/html/games auto uid=pi,gid=pi 0 0</code>
#Reboot.
#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====
Should work on Windows, Linux and MacOs:
#Install PHP 5 or greater for your system from https://www.php.net/downloads.
#Copy <code>PHPinfoil.php</code> in the folder where you store your games and rename it in <code>index.php</code>.
#Open terminal/cmd/bash/whatever.
#Type <code>ipconfig</code> or <code>ifconfig</code> command to get your current ip address.
#cd into your game folder.
#Type <code>php -S 0.0.0.0:80</code> to start php webserver.
#Set in Tinfoil a location to http://yourIp.at.step.4/
#Close and reopen Tinfoil.


==Media==
====Docker====
<youtube></youtube>
*Assuming your http server is serving at http://1.2.3.4:8080/
*Assuming the games are in /data/games folder of your http server.


Run:
docker run -d --rm -e HOST=1.2.3.4:8080 -v /data/games/:/var/www/html/data/games -p 8080:80 sbkg0002/phptinfoil:1


==Screenshots==
Build the image yourself:
https://dlhb.gamebrew.org/switchhomebrews/Switch-logo-01.png
<nowiki>git clone https://github.com/TheyKilledKenny/PHPinfoil.git</nowiki>
https://dlhb.gamebrew.org/switchhomebrews/Switch-logo-02.png
cd PHPinfoil
https://dlhb.gamebrew.org/switchhomebrews/Switch-logo-03.png
docker build -t phpinfoil .
https://dlhb.gamebrew.org/switchhomebrews/Switch-logo-04.png
https://dlhb.gamebrew.org/switchhomebrews/Switch-logo-05.png
https://dlhb.gamebrew.org/switchhomebrews/Switch-logo-06.png
https://dlhb.gamebrew.org/switchhomebrews/Switch-logo-07.png
https://dlhb.gamebrew.org/switchhomebrews/Switch-logo-08.png


==Changelog==
==Changelog==
'''v.1.0'''
'''v0.2 2021/06/07'''
* First Release.
* Added a bit of css and html to be more readable using standard web browsers if $DBI = true.
**Added parameters $BackColor, $ForeColor, $AltRowColor to change Background, Text and row colours.
*Added asort to the file array.
*A lot slower checking the file dimension, but now should not fail.
'''v0.1 2021/06/04'''
*First release Pre-release.
*Change the initial variable as your setup, please read readme.md.
*PHPinfoil.php can be renamed as you need for your setup.


== External links ==
== External links ==
* Gbatemp - https://gbatemp.net/threads/phpinfoil-single-php-file-to-host-your-own-game-for-tinfoil-or-dbi-no-gdrive-support-no-database.589272/
* GitHub - https://github.com/TheyKilledKenny/PHPinfoil
* Github - https://github.com/TheyKilledKenny/PHPinfoil
* GBAtemp - https://gbatemp.net/threads/phpinfoil-single-php-file-to-host-your-own-game-for-tinfoil-or-dbi-no-gdrive-support-no-database.589272/
* Reddit -

Latest revision as of 11:33, 20 Haziran 2023

PHPinfoil
Switch-logo.png
General
AuthorTheyKilledKenny
TypeGame Installer Companion
Version0.2
LicenseMixed
Last Updated2021/06/07
Links
Download
Website
Source

Simple PHP, one file, no database, no external library to serve your backups and eshop games to Tinfoil and DBI.

This was intended to be a lightlight, portable and fast PHP solution to create a Tinfoil repository for installing backups without cables. While similar projects exist, they lack the ability to manage a folder structure, which for some archives can also be articulated.

Moreover, there was no need to incorporate external services like GDrive or similar platforms. If you want to use GDrive or other external link, please check other more feature rich, projects like PHP Tinfoil Server.

Features

  • 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.

User guide

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.

Warning:

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;

Example:

Change the assumptions below to match your case:

  • Assuming your http server is serving at http://1.2.3.4:8080/
  • Assuming the games are in /data/games folder of your http server. so they can be downloaded from
    • http://1.2.3.4:8080/data/games/file[0100AD8015550000].nsp
    • or subfolders like
    • http://1.2.3.4:8080/data/games/mybackup/file[0100AD8015550000].nsp
  • Assuming you put this php file in /php so can be reached at http://1.2.3.4:8080/php/index.php
  • Assuming you have write permission on the /cache folder.
  • Assuming you want to list nsp, xci, nsz and xcz file types.

Set parameters with this values:

 $rootFolder = $_SERVER['DOCUMENT_ROOT'] . "/";
 $Folder = "data/games";
 $cacheFolder = "cache/";
 $cacheFile = "mycache.json";
 $arrExtensions = ['nsp','xci','nsz','xcz'];

in Tinfoil set a location to http://1.2.3.4:8080/php/

(the belows are quick examples, not intended for production environment)

Quick examples

Setup a Raspberry Pi and a USB HDD as personal shop

To 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 this index.php in the folder /var/www/html/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

Should work on Windows, Linux and 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.

Docker

  • Assuming your http server is serving at http://1.2.3.4:8080/
  • Assuming the games are in /data/games folder of your http server.

Run:

docker run -d --rm -e HOST=1.2.3.4:8080 -v /data/games/:/var/www/html/data/games -p 8080:80 sbkg0002/phptinfoil:1

Build the image yourself:

git clone https://github.com/TheyKilledKenny/PHPinfoil.git
cd PHPinfoil
docker build -t phpinfoil .

Changelog

v0.2 2021/06/07

  • Added a bit of css and html to be more readable using standard web browsers if $DBI = true.
    • Added parameters $BackColor, $ForeColor, $AltRowColor to change Background, Text and row colours.
  • Added asort to the file array.
  • A lot slower checking the file dimension, but now should not fail.

v0.1 2021/06/04

  • First release Pre-release.
  • Change the initial variable as your setup, please read readme.md.
  • PHPinfoil.php can be renamed as you need for your setup.

External links

Advertising: