Re: [PHP] Need Your Help :) I'm Just About Creating File Uploading Service

2009-04-16 Thread haliphax
On Thu, Apr 16, 2009 at 1:29 PM, Nitsan Bin-Nun nit...@binnun.co.il wrote:
 Hi List,

 I have been thinking for a while about setting up my own rapidshare.comclone,
 Few days back I went really serious with this and came up with some ideas.

 This is where I need your help, my partner and I have been thinking about
 the
 system that the website should run on.
 We came to conclusion that we are going to write it in PHP.

 There are several issues that came up during the mind-storm:
 First, how we can keep the files out of being published as direct links?

 My first idea was to host them one directory up from the http directory.
 It seems good but how I would deliver the files to the users?
 We are talking about unlimited file-size hosting so that means that we
 will have to stream the files somehow... and they will be BIG (it's
 defendant,
 about 700MB~ each)

 We thought of letting users pay by SMS'es, whats your ideas about it?

 I'm generally looking after a do and NOT do list of creating a file
 hoster ;)
 If you have any general ideas / precautions that would definitely make my
 partner and I happy :)

With files of that size and the transfer speed of most broadband
users, you will almost absolutely have to use a Flash/Java uploader
app in order to ensure the files finish before server/browser timeout.

As far as hiding them from being accessed directly, I think you're
right--the file itself will have to be outside of your web root. I
would probably use a middle system to grab a request from your page,
verify that it did in fact come from your page (maybe with a
time-sensitive hash value) and then retrieve the file's contents based
on the validity of that hash value.

Just a thought.


-- 
// Todd

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Need Your Help :) I'm Just About Creating File Uploading Service

2009-04-16 Thread Nitsan Bin-Nun
What is Amazon SSS??

On Thu, Apr 16, 2009 at 8:59 PM, Leonard Burton leonardbur...@gmail.comwrote:

 Why not use something like Amazon SSS and not worry about a lot of the
 details?

 On Thu, Apr 16, 2009 at 2:29 PM, Nitsan Bin-Nun nit...@binnun.co.il
 wrote:
  Hi List,
 
  I have been thinking for a while about setting up my own
 rapidshare.comclone,
  Few days back I went really serious with this and came up with some
 ideas.
 
  This is where I need your help, my partner and I have been thinking about
  the
  system that the website should run on.
  We came to conclusion that we are going to write it in PHP.
 
  There are several issues that came up during the mind-storm:
  First, how we can keep the files out of being published as direct links?
 
  My first idea was to host them one directory up from the http directory.
  It seems good but how I would deliver the files to the users?
  We are talking about unlimited file-size hosting so that means that we
  will have to stream the files somehow... and they will be BIG (it's
  defendant,
  about 700MB~ each)
 
  We thought of letting users pay by SMS'es, whats your ideas about it?
 
  I'm generally looking after a do and NOT do list of creating a file
  hoster ;)
  If you have any general ideas / precautions that would definitely make my
  partner and I happy :)
 
  Thanks in Advance,
  Nitsan
 



 --
 Leonard Burton, N9URK
 http://www.jiffyslides.com
 serv...@jiffyslides.com
 leonardbur...@gmail.com

 The prolonged evacuation would have dramatically affected the
 survivability of the occupants.



Re: [PHP] Need Your Help :) I'm Just About Creating File Uploading Service

2009-04-16 Thread 9el
Its Amazon S3 service. Which takes care of your CPU and scaling needs of
bandwidth. Good for CSS, JS and Image storing.


Re: [PHP] Need Your Help :) I'm Just About Creating File Uploading Service

2009-04-16 Thread Leonard Burton
http://aws.amazon.com/s3/

On Thu, Apr 16, 2009 at 3:10 PM, Nitsan Bin-Nun nit...@binnun.co.il wrote:
 What is Amazon SSS??

 On Thu, Apr 16, 2009 at 8:59 PM, Leonard Burton leonardbur...@gmail.com
 wrote:

 Why not use something like Amazon SSS and not worry about a lot of the
 details?

 On Thu, Apr 16, 2009 at 2:29 PM, Nitsan Bin-Nun nit...@binnun.co.il
 wrote:
  Hi List,
 
  I have been thinking for a while about setting up my own
  rapidshare.comclone,
  Few days back I went really serious with this and came up with some
  ideas.
 
  This is where I need your help, my partner and I have been thinking
  about
  the
  system that the website should run on.
  We came to conclusion that we are going to write it in PHP.
 
  There are several issues that came up during the mind-storm:
  First, how we can keep the files out of being published as direct links?
 
  My first idea was to host them one directory up from the http directory.
  It seems good but how I would deliver the files to the users?
  We are talking about unlimited file-size hosting so that means that we
  will have to stream the files somehow... and they will be BIG (it's
  defendant,
  about 700MB~ each)
 
  We thought of letting users pay by SMS'es, whats your ideas about it?
 
  I'm generally looking after a do and NOT do list of creating a file
  hoster ;)
  If you have any general ideas / precautions that would definitely make
  my
  partner and I happy :)
 
  Thanks in Advance,
  Nitsan
 



 --
 Leonard Burton, N9URK
 http://www.jiffyslides.com
 serv...@jiffyslides.com
 leonardbur...@gmail.com

 The prolonged evacuation would have dramatically affected the
 survivability of the occupants.





-- 
Leonard Burton, N9URK
http://www.jiffyslides.com
serv...@jiffyslides.com
leonardbur...@gmail.com

The prolonged evacuation would have dramatically affected the
survivability of the occupants.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Need Your Help :) I'm Just About Creating File Uploading Service

2009-04-16 Thread Michael A. Peters

Nitsan Bin-Nun wrote:

Hi List,

I have been thinking for a while about setting up my own rapidshare.comclone,
Few days back I went really serious with this and came up with some ideas.

This is where I need your help, my partner and I have been thinking about
the
system that the website should run on.
We came to conclusion that we are going to write it in PHP.

There are several issues that came up during the mind-storm:
First, how we can keep the files out of being published as direct links?

My first idea was to host them one directory up from the http directory.
It seems good but how I would deliver the files to the users?


php wrapper.
It validates (session id or whatever) that the client has permission to 
access the file, and then sends the real file.


$archive = /path/to/some/tarball;
$tarname = something.tar;

header(Pragma: public);
header(Expires: 0);
header(Cache-Control: must-revalidate, post-check=0, pre-check=0);
header(Cache-Control: private,false);

header('Content-type: application/x-tar');
header(Content-Disposition: attachment; filename= . $tarname);
header(Content-Transfer-Encoding: binary);
if ($fp = fopen( $archive , 'rb' )) {
   $sendOutput = ;
   while ($l = fgets($fp)) {
  $sendOutput .= $l;
  }
$outputLen = strlen($sendOutput);
header(Content-Length: $outputLen);
print $sendOutput;
} else {
// for whatever reason we failed
die();
}



We are talking about unlimited file-size hosting so that means that we
will have to stream the files somehow... and they will be BIG (it's
defendant,
about 700MB~ each)


Then I suggest setting up a torrent instead of direct download.
You can have protected torrents. I don't know how to set them up but I 
use them - there's a torrent site that requires I log in from the same 
IP as I'm running the torrent client from, for example.


If you want to provide service for those who can not use a torrent 
client, use an ftp server to serve the files - so that ftp clients 
capable of continuing an interrupted download can be used.


700MB is really too big fot http. Sure, it works, but it is better to 
use a protocol designed for large binary files.


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Need Your Help :) I'm Just About Creating File Uploading Service

2009-04-16 Thread Michael A. Peters

Michael A. Peters wrote:



$archive = /path/to/some/tarball;


should be $archive = '/path/to/some/tarball';

:D

rest of the code is copied from a file I use to serve content that is 
outside the web root.


That's one of my rules - the web server never has write permission to 
any directory inside the web root (I don't want a server bug to allow a 
cracker to trick the server into writing a file it then directly serves).


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Need Your Help :) I'm Just About Creating File Uploading Service

2009-04-16 Thread Nitsan Bin-Nun
My bad, I'm sending a copy to the list.

On Thu, Apr 16, 2009 at 9:37 PM, Nitsan Bin-Nun nit...@binnun.co.il wrote:

 Actually I don't much care for that, IMO 700MB~ is way too big for HTTP, I
 thought of giving away FTP links for download, but I have thought of the
 following:
 * First, there is a solution which will do this session validation/etc
 through .htaccess and will only rewrite it to the file instead of sending it
 in chunks? because that if the server will have to send it in chunks it will
 be a no-reason overkill for the CPU (calculating and reading these
 files. overkill).
 * Secondly, I thought of sending these 700MB~ through HTTP and giving away
 FTP links for the people who bought this functionality, I don't really care
 whether it works or not, as long as the website reputation is still up.

 I also have just signed a contract with downloads website which has 80k
 unique visitors/DAY!
 So I really have to think of scalability from the beginning of it,
 Do you have any ideas/notes/anything that I should take care of or keep in
 calculations when thinking of 80k crowd driving full speed on towards my
 server every DAY??

 Thanks in Advance,
 Nitsan


 On Thu, Apr 16, 2009 at 9:27 PM, Michael A. Peters mpet...@mac.comwrote:

 Nitsan Bin-Nun wrote:

 Hi List,

 I have been thinking for a while about setting up my own
 rapidshare.comclone,
 Few days back I went really serious with this and came up with some
 ideas.

 This is where I need your help, my partner and I have been thinking about
 the
 system that the website should run on.
 We came to conclusion that we are going to write it in PHP.

 There are several issues that came up during the mind-storm:
 First, how we can keep the files out of being published as direct links?

 My first idea was to host them one directory up from the http directory.
 It seems good but how I would deliver the files to the users?


 php wrapper.
 It validates (session id or whatever) that the client has permission to
 access the file, and then sends the real file.

 $archive = /path/to/some/tarball;
 $tarname = something.tar;

 header(Pragma: public);
 header(Expires: 0);
 header(Cache-Control: must-revalidate, post-check=0, pre-check=0);
 header(Cache-Control: private,false);

 header('Content-type: application/x-tar');
 header(Content-Disposition: attachment; filename= . $tarname);
 header(Content-Transfer-Encoding: binary);
 if ($fp = fopen( $archive , 'rb' )) {
   $sendOutput = ;
   while ($l = fgets($fp)) {
  $sendOutput .= $l;
  }
$outputLen = strlen($sendOutput);
header(Content-Length: $outputLen);
print $sendOutput;
} else {
// for whatever reason we failed
die();
}


  We are talking about unlimited file-size hosting so that means that we
 will have to stream the files somehow... and they will be BIG (it's
 defendant,
 about 700MB~ each)


 Then I suggest setting up a torrent instead of direct download.
 You can have protected torrents. I don't know how to set them up but I use
 them - there's a torrent site that requires I log in from the same IP as I'm
 running the torrent client from, for example.

 If you want to provide service for those who can not use a torrent client,
 use an ftp server to serve the files - so that ftp clients capable of
 continuing an interrupted download can be used.

 700MB is really too big fot http. Sure, it works, but it is better to use
 a protocol designed for large binary files.





RE: [PHP] Need Your Help :) I'm Just About Creating File Uploading Service

2009-04-16 Thread kyle.smith
How is 700MB too big for HTTP?  Ever download a linux distro?  Ever
benchmark FTP vs HTTP, the overhead is minimal... 


 
--
Kyle Smith
Unix Systems Administrator

-Original Message-
From: Nitsan Bin-Nun [mailto:nit...@binnun.co.il] 
Sent: Thursday, April 16, 2009 3:37 PM
To: PHP General List
Subject: Re: [PHP] Need Your Help :) I'm Just About Creating File
Uploading Service

My bad, I'm sending a copy to the list.

On Thu, Apr 16, 2009 at 9:37 PM, Nitsan Bin-Nun nit...@binnun.co.il
wrote:

 Actually I don't much care for that, IMO 700MB~ is way too big for 
 HTTP, I thought of giving away FTP links for download, but I have 
 thought of the
 following:
 * First, there is a solution which will do this session validation/etc

 through .htaccess and will only rewrite it to the file instead of 
 sending it in chunks? because that if the server will have to send it 
 in chunks it will be a no-reason overkill for the CPU (calculating and

 reading these files. overkill).
 * Secondly, I thought of sending these 700MB~ through HTTP and giving 
 away FTP links for the people who bought this functionality, I don't 
 really care whether it works or not, as long as the website reputation
is still up.

 I also have just signed a contract with downloads website which has 
 80k unique visitors/DAY!
 So I really have to think of scalability from the beginning of it, Do 
 you have any ideas/notes/anything that I should take care of or keep 
 in calculations when thinking of 80k crowd driving full speed on 
 towards my server every DAY??

 Thanks in Advance,
 Nitsan


 On Thu, Apr 16, 2009 at 9:27 PM, Michael A. Peters
mpet...@mac.comwrote:

 Nitsan Bin-Nun wrote:

 Hi List,

 I have been thinking for a while about setting up my own 
 rapidshare.comclone, Few days back I went really serious with this 
 and came up with some ideas.

 This is where I need your help, my partner and I have been thinking 
 about the system that the website should run on.
 We came to conclusion that we are going to write it in PHP.

 There are several issues that came up during the mind-storm:
 First, how we can keep the files out of being published as direct
links?

 My first idea was to host them one directory up from the http
directory.
 It seems good but how I would deliver the files to the users?


 php wrapper.
 It validates (session id or whatever) that the client has permission 
 to access the file, and then sends the real file.

 $archive = /path/to/some/tarball;
 $tarname = something.tar;

 header(Pragma: public);
 header(Expires: 0);
 header(Cache-Control: must-revalidate, post-check=0, pre-check=0);
 header(Cache-Control: private,false);

 header('Content-type: application/x-tar');
 header(Content-Disposition: attachment; filename= . $tarname);
 header(Content-Transfer-Encoding: binary); if ($fp = fopen( 
 $archive , 'rb' )) {
   $sendOutput = ;
   while ($l = fgets($fp)) {
  $sendOutput .= $l;
  }
$outputLen = strlen($sendOutput);
header(Content-Length: $outputLen);
print $sendOutput;
} else {
// for whatever reason we failed
die();
}


  We are talking about unlimited file-size hosting so that means that 
 we
 will have to stream the files somehow... and they will be BIG (it's 
 defendant, about 700MB~ each)


 Then I suggest setting up a torrent instead of direct download.
 You can have protected torrents. I don't know how to set them up but
I use
 them - there's a torrent site that requires I log in from the same IP
as I'm
 running the torrent client from, for example.

 If you want to provide service for those who can not use a torrent
client,
 use an ftp server to serve the files - so that ftp clients capable of
 continuing an interrupted download can be used.

 700MB is really too big fot http. Sure, it works, but it is better to
use
 a protocol designed for large binary files.




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Need Your Help :) I'm Just About Creating File Uploading Service

2009-04-16 Thread Paul M Foster
On Thu, Apr 16, 2009 at 12:27:38PM -0700, Michael A. Peters wrote:

snip

 We are talking about unlimited file-size hosting so that means that we
 will have to stream the files somehow... and they will be BIG (it's
 defendant,
 about 700MB~ each)

 Then I suggest setting up a torrent instead of direct download.
 You can have protected torrents. I don't know how to set them up but I
 use them - there's a torrent site that requires I log in from the same
 IP as I'm running the torrent client from, for example.

A torrent is only fast or faster because you can get various pieces of
the file from various peers or servers on the internet, simultaneously.
I don't expect that people uploading their private photos of their
girlfriends want them shared in any way, except with the eventual
recipient.

Paul

-- 
Paul M. Foster

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Need Your Help :) I'm Just About Creating File Uploading Service

2009-04-16 Thread Michael A. Peters

kyle.smith wrote:

How is 700MB too big for HTTP?  Ever download a linux distro?  Ever
benchmark FTP vs HTTP, the overhead is minimal... 


I download linux distro's all the time - er, whenever a new CentOS is 
released.


It's not overhead that is the issue.
It's being able to continue an interrupted download that is an issue.

Some http clients may be able to, though I suspect that would require a 
non standard extension to http that both client and server understand.


Also - many people use a temp filesystem (aka ram disk) for www 
downloads (I doubt a majority but those of us who are smart) - where the 
file is initially put until all the pieces have come down before it is 
finally saved to the destination. Using tempfs for that requires less 
disk IO because your www downloads are typically small, so no need to 
write to disk until you have it all when it can do the write at once.


700MB can easily fill that temp filesystem, depending upon the size of 
your tempfs (and what else it is being used for).


Serving via ftp - virtually every ftp client out there knows how to 
resume an interrupted download, so it is much better suited for large 
downloads than http. And serving via ftp/torrent - the user is far less 
likely to be using a tempfs as a staging area that can result in a bad 
download.


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Need Your Help :) I'm Just About Creating File Uploading Service

2009-04-16 Thread Michael A. Peters

Paul M Foster wrote:


Then I suggest setting up a torrent instead of direct download.
You can have protected torrents. I don't know how to set them up but I
use them - there's a torrent site that requires I log in from the same
IP as I'm running the torrent client from, for example.


A torrent is only fast or faster because you can get various pieces of
the file from various peers or servers on the internet, simultaneously.
I don't expect that people uploading their private photos of their
girlfriends want them shared in any way, except with the eventual
recipient.

Paul



The point of torrent isn't speed - but because torrent is excellent at 
dealing with interruption in network before the download is complete, 
and far less likely to result in a bad download.


In fact - I've used torrent to fix files that were improperly downloaded 
without having to download them again.


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Need Your Help :) I'm Just About Creating File Uploading Service

2009-04-16 Thread Ashley Sheridan
On Thu, 2009-04-16 at 13:31 -0700, Michael A. Peters wrote:
 Paul M Foster wrote:
 
  Then I suggest setting up a torrent instead of direct download.
  You can have protected torrents. I don't know how to set them up but I
  use them - there's a torrent site that requires I log in from the same
  IP as I'm running the torrent client from, for example.
  
  A torrent is only fast or faster because you can get various pieces of
  the file from various peers or servers on the internet, simultaneously.
  I don't expect that people uploading their private photos of their
  girlfriends want them shared in any way, except with the eventual
  recipient.
  
  Paul
  
 
 The point of torrent isn't speed - but because torrent is excellent at 
 dealing with interruption in network before the download is complete, 
 and far less likely to result in a bad download.
 
 In fact - I've used torrent to fix files that were improperly downloaded 
 without having to download them again.
 
But a torrent in this case is entirely unsuitable as the op said. As far
as I'm aware, HTTP is fine for downloads, and it's served me fine using
it, but uploads are a different matter. Using FTP for both would
certainly solve a lot of issues however.


Ash
www.ashleysheridan.co.uk


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Need Your Help :) I'm Just About Creating File Uploading Service

2009-04-16 Thread Nitsan Bin-Nun
You are definitely right, but there is one thing that you didn't knew and
I'm sure that you didn't take into account - usually the files on the server
will be DVD rip's that are typically 700MB~ in size, every second movie that
people will download will contain some interrupted pieces, although that
these small pieces won't affect the file that much in order to keep it out
from playing. Most of the video players know how to player these corrupted
files and will handle them good.

And for torrent - this is a good solution but this is not what I'm after,
I'm going to set up an HTTP file hoster, not a torrent tracker ;)

Any other ideas regarding serving the files and hosting them will be very
appreciated!!

Thank you guys for all the ongoing help in this list ;)

Kind Regards,
Nitsan

On Thu, Apr 16, 2009 at 10:29 PM, Michael A. Peters mpet...@mac.com wrote:

 kyle.smith wrote:

 How is 700MB too big for HTTP?  Ever download a linux distro?  Ever
 benchmark FTP vs HTTP, the overhead is minimal...


 I download linux distro's all the time - er, whenever a new CentOS is
 released.

 It's not overhead that is the issue.
 It's being able to continue an interrupted download that is an issue.

 Some http clients may be able to, though I suspect that would require a non
 standard extension to http that both client and server understand.

 Also - many people use a temp filesystem (aka ram disk) for www downloads
 (I doubt a majority but those of us who are smart) - where the file is
 initially put until all the pieces have come down before it is finally saved
 to the destination. Using tempfs for that requires less disk IO because your
 www downloads are typically small, so no need to write to disk until you
 have it all when it can do the write at once.

 700MB can easily fill that temp filesystem, depending upon the size of your
 tempfs (and what else it is being used for).

 Serving via ftp - virtually every ftp client out there knows how to resume
 an interrupted download, so it is much better suited for large downloads
 than http. And serving via ftp/torrent - the user is far less likely to be
 using a tempfs as a staging area that can result in a bad download.



Re: [PHP] Need Your Help :) I'm Just About Creating File Uploading Service

2009-04-16 Thread Michael A. Peters

Michael A. Peters wrote:

kyle.smith wrote:

How is 700MB too big for HTTP?  Ever download a linux distro?  Ever
benchmark FTP vs HTTP, the overhead is minimal... 


I download linux distro's all the time - er, whenever a new CentOS is 
released.


It's not overhead that is the issue.
It's being able to continue an interrupted download that is an issue.


Resuming interrupted downloads when you are using php to serve a file 
not in the document root is probably even trickier.


If you don't mind your server doing that, then go ahead and use http - 
but it will result in increased bandwidth from browsers that crashed, 
network hickups, etc.


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Need Your Help :) I'm Just About Creating File Uploading Service

2009-04-16 Thread Nitsan Bin-Nun
Neh, we don't have plenty of these in Israel, don't count it in as an issue.

Serving the files won't be an overkill for my harddrive / cpu usage /
anything else?

There is a better way to serve the files with/without PHP and keeping them
outsite of the HTTP root?

Thanks in Advance,
Nitsan

On Thu, Apr 16, 2009 at 10:43 PM, Michael A. Peters mpet...@mac.com wrote:

 Michael A. Peters wrote:

 kyle.smith wrote:

 How is 700MB too big for HTTP?  Ever download a linux distro?  Ever
 benchmark FTP vs HTTP, the overhead is minimal...


 I download linux distro's all the time - er, whenever a new CentOS is
 released.

 It's not overhead that is the issue.
 It's being able to continue an interrupted download that is an issue.


 Resuming interrupted downloads when you are using php to serve a file not
 in the document root is probably even trickier.

 If you don't mind your server doing that, then go ahead and use http - but
 it will result in increased bandwidth from browsers that crashed, network
 hickups, etc.



Re: [PHP] Need Your Help :) I'm Just About Creating File Uploading Service

2009-04-16 Thread Michael A. Peters

Nitsan Bin-Nun wrote:

Neh, we don't have plenty of these in Israel, don't count it in as an issue.

Serving the files won't be an overkill for my harddrive / cpu usage /
anything else?

There is a better way to serve the files with/without PHP and keeping them
outsite of the HTTP root?


If you want to use http the code I provided in my first response works 
very well for files I serve outside the web root.


make a dummy directory in the web root.
In that dummy directory put a single php file - called dummy.php or 
whatever.


Have that file check the users credentials etc. (IE via session id) - 
and have


$thispage=$_SERVER['REQUEST_URI'];

put a .htaccess file in the dummy directory containing:

RewriteEngine on
RewriteRule ^*\.iso$ dummy.php

That way a request to /dummy/something.iso

is handled by dummy.php - which then can figure out what file is wanted 
via the $thispage variable, verify the user has permission to download 
it via sessions etc. (and sends a 403 header if they don't), verifies 
that the file exists (and sends a 404 header if it doesn't), and then 
uses the code I outlined in my first post to grab the file from the real 
location that is outside the web root and sends it to the requesting client.


It works quite well for me.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Need Your Help :) I'm Just About Creating File Uploading Service

2009-04-16 Thread Michael A. Peters

Michael A. Peters wrote:

Nitsan Bin-Nun wrote:
Neh, we don't have plenty of these in Israel, don't count it in as an 
issue.


Serving the files won't be an overkill for my harddrive / cpu usage /
anything else?

There is a better way to serve the files with/without PHP and keeping 
them

outsite of the HTTP root?


If you want to use http the code I provided in my first response works 
very well for files I serve outside the web root.


make a dummy directory in the web root.
In that dummy directory put a single php file - called dummy.php or 
whatever.


Have that file check the users credentials etc. (IE via session id) - 
and have


$thispage=$_SERVER['REQUEST_URI'];

put a .htaccess file in the dummy directory containing:

RewriteEngine on
RewriteRule ^*\.iso$ dummy.php


That assumes apache is your server, you have the mod_rewrite module, and 
allow .htaccess override (if you don't want to allow .htaccess overide 
you can put the rewrite directive right in the http.conf for the dummy 
directory)


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Need Your Help :) I'm Just About Creating File Uploading Service

2009-04-16 Thread Nitsan Bin-Nun
It's really simple and I wrote several of these long time before, but I
thought that there might be an option of serving the files w/o using PHP to
read it and send the headers and chunks using only htaccess for the serving
and PHP for the validation of the session.

On Thu, Apr 16, 2009 at 10:58 PM, Michael A. Peters mpet...@mac.com wrote:

 Nitsan Bin-Nun wrote:

 Neh, we don't have plenty of these in Israel, don't count it in as an
 issue.

 Serving the files won't be an overkill for my harddrive / cpu usage /
 anything else?

 There is a better way to serve the files with/without PHP and keeping them
 outsite of the HTTP root?


 If you want to use http the code I provided in my first response works very
 well for files I serve outside the web root.

 make a dummy directory in the web root.
 In that dummy directory put a single php file - called dummy.php or
 whatever.

 Have that file check the users credentials etc. (IE via session id) - and
 have

 $thispage=$_SERVER['REQUEST_URI'];

 put a .htaccess file in the dummy directory containing:

 RewriteEngine on
 RewriteRule ^*\.iso$ dummy.php

 That way a request to /dummy/something.iso

 is handled by dummy.php - which then can figure out what file is wanted via
 the $thispage variable, verify the user has permission to download it via
 sessions etc. (and sends a 403 header if they don't), verifies that the file
 exists (and sends a 404 header if it doesn't), and then uses the code I
 outlined in my first post to grab the file from the real location that is
 outside the web root and sends it to the requesting client.

 It works quite well for me.



Re: [PHP] Need Your Help :) I'm Just About Creating File Uploading Service

2009-04-16 Thread Michael A. Peters

Nitsan Bin-Nun wrote:

It's really simple and I wrote several of these long time before, but I
thought that there might be an option of serving the files w/o using PHP to
read it and send the headers and chunks using only htaccess for the serving
and PHP for the validation of the session.


There might be - I'm not familiar with such a technique though.
You may be able to use php sessions to enter an IP into a database (or 
flat file) that standard apache access restrictions could use to 
determine whether or not to send the file.


IE upon succesful login from 192.168.15.7 - that IP is added to a list 
used in an apache allow from directive.


The potential problem I see with that is the IP address you associate 
with a session may be a proxy.


But there may be solutions to that.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php