Looks alright, isn't very efficient but it does the job
|
Yes, those links need's to be direct. What do you mean with using page's in webhost? You mean redirecting to somewhere?
If my 1. host was addddd.com, then it would beIf my 2. host was asdasd.com, then it would beCode:$file = 'addddd.com/client.jar';Code:$file2 = 'asdasd.com/client.jar';
This is HORRIBLE, EVERYTHING will go through your main server, no real distribution of the file load.
It will have it's uses, but most people won't need it. I can only see this working ok for maybe a download that requires a login/whatever, but otherwise it'll use double the bandwidth and is limited by the speed of the transfer between hosts.
Just use header('Location: ' . $file1); and die(), way simpler, splits it between hosts even more.
And, use an array for files, instead of having 2 different variables simply loop through them until the file exists
The way readfile works is that it reads from the file then outputs over the original connection, since you are transferring it from one server to the main one before sending to the clients, you are doubling the bandwidth used server side.
Oh, and this code is pretty much the first example of readfile with a couple lines added.
Best way to do it is simply using the header function and redirecting to the file
Edit: Foreach is an awesome tool.
Code:<?php //links, change these. $arr = array('host1' => 'http://mydomain.com/client.jar', 'host2' => 'http://mydomain.net/client.jar'); foreach($arr as $hostname => $file) { if(file_exists($file)) { header('Location: ' . $file); die(); } } ?>
« Previous Thread | Next Thread » |
Thread Information |
Users Browsing this ThreadThere are currently 1 users browsing this thread. (0 members and 1 guests) |