Post: File Downloader Code (For SPRX)
07-24-2017, 10:30 PM #1
Tustin
Balls of Steel
(adsbygoogle = window.adsbygoogle || []).push({}); I wrote this code with the intention of making a auto updater for Lexicon a while back but ran into problems with file permissions so it was never used. Figured someone here could find it useful for something. You need to add this code to your sprx project, and then create a listening server in whatever language you want to serve the file.


C++ code: (I can't remember if the progress bar thing worked properly or not)



Server code (written in PHP =Z):



This is a basic example that will help you get started. Although if you want to modify this any further you probably want to do some research on socket programming before messing with this.
Last edited by Tustin ; 07-24-2017 at 10:34 PM.

The following 2 users say thank you to Tustin for this useful post:

PhucedMODZ, Smoulougde
08-21-2017, 11:58 AM #20
Smoulougde
S.P.E.C.I.A.L
Originally posted by Tustin View Post
I wrote this code with the intention of making a auto updater for Lexicon a while back but ran into problems with file permissions so it was never used. Figured someone here could find it useful for something. You need to add this code to your sprx project, and then create a listening server in whatever language you want to serve the file.


C++ code: (I can't remember if the progress bar thing worked properly or not)



Server code (written in PHP =Z):



This is a basic example that will help you get started. Although if you want to modify this any further you probably want to do some research on socket programming before messing with this.


Hi Tustin, i have tried your coding for download the file version.galerium (for after read this file and check if version is superior compared current version menu)
And the file downloaded is empty, 0B and none char included into file, i have tried with other files, it's same...
You can check my coding for see if one thing is wrong please...? You must login or register to view this content.
08-21-2017, 03:30 PM #21
Tustin
Balls of Steel
Originally posted by Smoulougde View Post
Hi Tustin, i have tried your coding for download the file version.galerium (for after read this file and check if version is superior compared current version menu)
And the file downloaded is empty, 0B and none char included into file, i have tried with other files, it's same...
You can check my coding for see if one thing is wrong please...? You must login or register to view this content.

Make sure that the file's directory is relative to the location of the script. Say you put the php script inside /home/ and you execute it from there. The FILE_NAME constant should be where the file is located relative to the php script. Try just putting your version.galerium file in the same directory as your php script and then changing FILE_NAME to "version.galerium". It should send the file properly if that was your issue.
08-21-2017, 06:56 PM #22
Smoulougde
S.P.E.C.I.A.L
Originally posted by Tustin View Post
Make sure that the file's directory is relative to the location of the script. Say you put the php script inside /home/ and you execute it from there. The FILE_NAME constant should be where the file is located relative to the php script. Try just putting your version.galerium file in the same directory as your php script and then changing FILE_NAME to "version.galerium". It should send the file properly if that was your issue.


Ok i see... But file version.galerium is in folder and it's right i think related php coding > You must login or register to view this content.
I will try tomorrow with version.galerium in same folder of php file, but i don't think it's this...
Last edited by Smoulougde ; 08-21-2017 at 07:03 PM.
08-22-2017, 01:14 PM #23
Smoulougde
S.P.E.C.I.A.L
Originally posted by Tustin View Post
Make sure that the file's directory is relative to the location of the script. Say you put the php script inside /home/ and you execute it from there. The FILE_NAME constant should be where the file is located relative to the php script. Try just putting your version.galerium file in the same directory as your php script and then changing FILE_NAME to "version.galerium". It should send the file properly if that was your issue.


It's same... The file is empty : 0B and no char in the file... Even if I put the file in the same folder as the php
08-22-2017, 01:49 PM #24
Tustin
Balls of Steel
Originally posted by Smoulougde View Post
It's same... The file is empty : 0B and no char in the file... Even if I put the file in the same folder as the php

You have the script running before you try to download the file, right? The script runs in an infinite loop and will accept all clients who connect to it so you'll want to execute the script from the ssh terminal and leave that open while you run the SPRX. After that, you can use the nohup command to keep the script running indefinitely (until it hits an error or something) even after you close the ssh connection:
    nohup php script.php &
08-22-2017, 02:04 PM #25
Smoulougde
S.P.E.C.I.A.L
Originally posted by Tustin View Post
You have the script running before you try to download the file, right? The script runs in an infinite loop and will accept all clients who connect to it so you'll want to execute the script from the ssh terminal and leave that open while you run the SPRX. After that, you can use the nohup command to keep the script running indefinitely (until it hits an error or something) even after you close the ssh connection:
    nohup php script.php &


Sorry i do not know much about site, where I must put the line nohup php script.php & ?

In my sprx i have put CheckVersion after message "welcome" > You must login or register to view this content.
08-24-2017, 11:08 AM #26
Originally posted by Tustin View Post
Tried it and it gave the same error I got when I tried unlinking the sprx too.

then i would say ..replace the eboot.bin ( with download ) and name the sprx differently so the eboot loads the new sprx and remove old sprx ? with the new sprx
05-12-2019, 06:31 PM #27
Brilliant, I like this method, File perms can be set using " cellFsChmod(fileName, CELL_FS_S_IFMT | 0777); " . I did it a different way but this is very interesting to look at, I'll credit you if I decide to try this method.

Copyright © 2024, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo