Use ftp as http for counter-strike source (sv_downloadurl)

Alxs

Limp Gawd
Joined
Apr 7, 2007
Messages
398
I want to have fast download for custom maps on my server so I created a ftp server. It works, but the downloads are not faster. I read that it was because sv_downloadurl only accepts http server. The thing is, my host (freehostingcloud.com) is currently bugged when I try to install a web script (php nuke). I read that it was possible to run a ftp server under http with a script. I know this is possible because I used to borrow a ftp server and the address was starting with http instead of ftp, and the downloads were fast. So my question is, how can I make my ftp appears as http? Or how can I make it upload fast on counter-strike server? It should be between 1-2 mbps, but now it's like 25kbps..
 
I'm new at hosting http and php. I'm not sure what to do with this code snippet. I don't even know where to put this :( can you give me some more explanations?

Thanks for your time
 
Just make a text file and paste the code in to it and call it download.php and put it on your web server. Of course you'll have to change the ftp details and file name.

Then to download the ftp file go to http://yourWebServer/download.php

The php script connects to the remote ftp and converts it to a http download.
 
Actually I doubt that would work if the file is very big. It would be more complicated you'd have to chunk it in to smaller pieces.
 
Then how can I simply host my files on my http? Or at least make text appear when I load my page...

Edit : the web provider also gives mysql, maybe it would be a better way to host files?
 
Here it is chunked in to 1mb pieces which should work with big files. I tested it with the public ftp below.

Change ftp://ftp.kernel.org/pub/linux/utils/util-linux-ng/v2.13-pre/util-linux-2.13-pre1.tar.gz

to

PHP:
ftp://username:password@yourFTP/dirname/filename

and change the filename=test.tar.gz to the name of the FTP file.


PHP:
<?php

define('CHUNK_SIZE', 1024*1024); // Size (in bytes) of tiles chunk

  // Read a file and display its content chunk by chunk
  function readfile_chunked($filename, $retbytes = TRUE) {
    $buffer = '';
    $cnt =0;
    // $handle = fopen($filename, 'rb');
    $handle = fopen($filename, 'rb');
    if ($handle === false) {
      return false;
    }
    while (!feof($handle)) {
      $buffer = fread($handle, CHUNK_SIZE);
      echo $buffer;
      ob_flush();
      flush();
      if ($retbytes) {
        $cnt += strlen($buffer);
      }
    }
    $status = fclose($handle);
    if ($retbytes && $status) {
      return $cnt; // return num. bytes delivered like readfile() does.
    }
    return $status;
  }

header("Content-type: application/octet-stream");
header("Content-disposition: attachment; filename=test.tar.gz");
readfile_chunked('ftp://ftp.kernel.org/pub/linux/utils/util-linux-ng/v2.13-pre/util-linux-2.13-pre1.tar.gz');

?>
 
What if I have multiple files? Do I have to copy all that code for each file?
 
3 - Configure the DNS for your domain name through your registrar to point to your host's DNS servers. This is important since it will allow other people to access your site through your domain name.

Hmm, maybe that's why nothing works?

Sorry for so many questions, I'm starting to realize I have to learn how to properly host a website before trying to implement a script I don't understand..
 
Back
Top