I am currently implementing a new way for themes to be submitted on PS3 Themes. Allowing users to select a remote P3T file and it will be downloaded. There is multiple ways of doing this, but the simplest method is using cURL. The cURL options you will need are CURLOPT_TIMEOUT, CURLOPT_FILE and CURLOPT_FOLLOWLOCATION and you will need the function
The code is fairly straight forward, and if not, the comments should help.
Hosh
fopen()
. So here goes.Highlighted using GeSHi
- <?php
- $f = fopen('theme_name.p3t', 'w+'); // Initiate a file writer for the downloaded file to be written to.
- // set the appropriate options
- curl_setopt($d, CURLOPT_TIMEOUT, 60); // set the time out time for the cURL operation, the bigger the file, the bigger this number should be
- curl_setopt($d, CURLOPT_FILE, $f); // this is where you need the file handle, it will put everything straight handle
- curl_setopt($d, CURLOPT_FOLLOWLOCATION, true); // this is just so all redirects are actually, otherwise might get the wrong page.
- // Execute cURL, this will set it
- // close both the file handle and the cURL
- ?>
Hosh
Good stuff! Thanks for sharing man
ReplyDeletethanks for the tip!
ReplyDeletei could definitely use that
ReplyDeleteIs this just a hobby or are you studying it?
ReplyDeleteI learnt a bit of php and phyton (<way easier) but gave up... heh.
Very nifty, I wonder if i'll be able to use it right lol
ReplyDeleteThat might come in handy. Thank you for sharing your knowledge on PHP.
ReplyDeleteThanks for the tip.
ReplyDeleteyou're all welcome.
ReplyDelete@Anonwadi
It started out as a hobby, but also studying this stuff now. and I have seen python, I will be starting to learn that soon as well.
oh i see
ReplyDelete