dreamhost - output a file based on condition - PHP -


i want make php file, information user information (browser, platform, version ...) , if user comes mobile, i'll output mp3 file average size: 20 mb.

i expect on average 30,000 users/day, register dreamhost shared hosting plan, think plan can load such traffic, requests , processing?

what best way on php fetch such information, insert database , output file based on condition?

to detect if user on mobile device can use php-mobile-detect class. it's lot easier writing own accommodate of devices.

you'll need watch traffic patterns determine whether need larger hosting plan or not. 30,000 visitors lot of visitors. 30,000 pageviews might more begin (or 30,000 visits). being said server load depend on when come. 500 visitors connecting machine downloading same file @ once can bring down. on shared hosting ds they'll try have upgrade vps plan or box you're if you're receiving enough traffic compromise other people on cluster. they enable throttling if site requires resources.

in terms of providing link , limiting legitimate traffic, can verify ip address ($_server['remote_addr']), session id (session()), viewtime, , pass script header redirection prevent people accessing shared link:

http://domain.com/download.php?f=04293d&ts=1367827755&t=25d55ad283aa400af464c76d713c07ad 

on page delivering file can verify it's same user, same session (in case it's linking on local network) , timestamp.

<?php     session_start();     if(!empty($_get['f'])){     $f = $_get['f'];     } else {      exit();     }      if(!empty($_get['ts'])&&preg_match('!^[0-9]+$!',$_get['ts'])){      $tsin = $_get['ts'];     } else {      exit();     }      $testhash = md5($_server['remote_addr'].session_id().$tsin.'s@lt3d');      if(!empty($_get['t'])&&$testhash==$_get['t']){      // we'll outputting mp3     header('content-type: audio/mpeg');      // called audio.mp3     header('content-disposition: attachment; filename="audio.mp3"');      // prevent mining mp3 source in safe folder named '/._mp3s_safe/'     readfile($_server['document_root'].'/._mp3s_safe/original.mp3');      } else {       exit();     } ?> 

i've not included in code, can check see if file requested within amount of time. can verify users requiring them provide email address, email them link download file if traffic issue. can use timestamp hashing method see if using program downloads. if they've downloaded file or have many other downloads open can make them wait file or make script stop error traffic machine.


Comments