I spent a while trying to look up codes to make a premium filesonic generator. I failed to obtain a full proof resource so I decided to take matter in my own hands. It took a while but I did complete the challenge. My coding skills are some where between noob and decent. But the end result is pretty satisfying and spot on. I think my script can easily be integrated into a full fledged premium generator script. I don’t expect revenue sharing but could really use some credit.
This is the first part of the code. It is a text form where you accept the file urls to generate premium links. The code supports multiple links. Each link should be on a different line. The code will pass the data to another php file via ‘post’ where it will be processed further.
It is a pretty basic form code which will generate a text box of the size of 4 rows and 70 columns and submit button with the message “Generate Filesonic Premium Link”. As you can see in this code we are passing this information to a file called ‘in.php’
The following is the code of “in.php” . First, we’ll need to receive and store the information. Once the information is stored we’ll need to validate and process it. I know it sounds pretty complicated but trust me its not.
I will explain the above code line by line now .
Line 1: This fetches the data passed by the form.
Line 2 : This is a regex code to identify space in a line. It is basically to tidy up the urls of free space. This free space can make the URLs look broken.
Line 3: This is a variable defined with the purpose of replacing the spaces once they are identified. The variable is basically nothing.
Line 4: It is the regex to extract the file id of filesonic downloads which will be used later.
Line 5: The data passed on to the php file is processed. The urls are passed as a chunk. They are now broken down on basis of new line.
Line 6: Free spaces are omitted from the urls.
Now the next step includes a series of validations to make sure that the URL supplied to us is a valid filesonic URL. This validation is very important. If the data is not validated, your server can be abused and your premium id can be stolen.
Line 1 : A variable is defined which will be used later as a count variable.
Line 2 : Another variable is defined which will be used for validation purpose later on. This value has to be changed to “wupload” if you are looking to make a wupload premium generator.
Line 3 : it is a flag variable which is used in the loop.
Line 4 : It is a loop that goes on till all the Urls are processed.
Line 6: The value of a individual URL is stored further in another variable for processing purpose.
Line 7: A regex match is done to see if the url supplied is a valid url.
Line 8-24 : It is used to validate if the supplied url is a filesonic url or not. If yes it is stored in a new array where it will be processed later or else a message will be output.
The next batch of code mainly extracts the unique file id of each file specified. It is this through this id premium file links are generated.
Line 1 : The processed valid filesonic links are stored in another variable for processing.
Line 2: A dummy check variable is specified.
Line 3-19: The main purpose of this part of the code is to extract the unique file id of each file and store it.
Line 1 : The unique file ids generated are further checked for free space. If free space is found it is fixed.
Line 2: The number of valid links inputted by the users are counted.
Line 3-10 : This batch of code makes sure not more than 6 downloads are generated by a user at one time.
Line 11-18 : This passes the extracted file id to a new file called dupe.php. The url is passed as a iframe because I want the user to download the file without exposing my premium user and id which is a part of the premium url. Now when the user checks for his download URL he will see this dupe.php as the download source.
Now we’ll talk about dupe.php. This php file’s code’s major aim is to start the download process without exposing the premium credentials.
Line 1: We’ll be defining a new function to start download of a url. The function will accept a valid file id and construct a premium filesonic link based on that and then start download.
Line 3: This is a variable that stores the front part of the filesonic premium url which is valid for all premium urls.
Line 4: This is where you put your filesonic premium user id .
Line 5: This is where you put your filesonic password.
Line 6: This uses the supplied filesonic username and password to generate a premium filesonic URL. This is how you generate a premium download via the filesonic api.
Line 7-14: Generating a download is not so easy after all. On the premium URL you generated, there is a xml file with the download URL and the download filename. This both will be needed to generate a download link. This part used cURL, so please make sure you have cURL active on your server.
Line 15: The extracted file name from the xml file accessed via the premium file link is stored in another variable.
Line 16: Similarly, the final download URL is stored in another variable.
Line 17-21 : This part of the code starts a data stream. The data is loaded on to the server and further supplied to the end user.
Line 24: This where the unique file id is fetched.
line 25: This is where the function is called and the file id parameter is supplied.
Line 1 : Fetched the Unique file id of the download.
Line 2: Calls the functions down and passes the file id into the function.
This is my first ever coding tutorial so I don’t really know how well I did. But I hope you absorbed major fraction of the code. I had to use pastie because the wordpress plugin for this was acting up. Probably I ll revert back to the coding style once I know it works properly.
To convert this to a wupload premium file link generator, all you need to do is replace “filesonic” by “wupload”. They have the same api which makes me think they have the same owner.
Here are the full files for download.