[PHP] file downloads using header problem

2004-02-09 Thread Joshua Minnie
I am trying to force a file download using headers.  The problem is not
forcing the download.  That is working fine, but if the user wants to click
on another download while the first one is still downloading it won't let
the user do it.

Here is the code that I'm using, adapted from phpbuilder.com:

?php
$pathtofile = '\abs\path\to\file\'.urldecode( $_GET['link'] );
$download = 'http://www.somewhere.com'.urldecode( $_GET['link'] );
$type = urldecode( $_GET['type'] );
$size = filesize( $pathtofile );
header(Pragma: private);
header(Expires: 0); // set expiration time
header(Cache-Control: must-revalidate, post-check=0, pre-check=0);
// browser must download file from server instead of cache

// force download dialog
header(Content-Type: application/force-download);
header(Content-Type: application/octet-stream);
header(Content-Type: application/download);
header(Content-Type: $type);

// use the Content-Disposition header to supply a recommended filename
and
// force the browser to display the save dialog.
header(Content-Disposition: attachment;
filename=.basename($download).;);

/*
The Content-transfer-encoding header should be binary, since the file
will be read
directly from the disk and the raw bytes passed to the downloading
computer.
The Content-length header is useful to set for downloads. The browser
will be able to
show a progress meter as a file downloads. The content-lenght can be
determines by
filesize function returns the size of a file.
*/
header(Content-Transfer-Encoding: binary);
header(Accept-Ranges: bytes);
header(Content-Length: $size);

$fh = fopen( $pathtofile , rb);
fpassthru($fh);
fclose($fh);
?
[after this the html content is displayed]

Does anybody have any idea to allow for multiple downloads while another one
was going on.  Maybe some additional headers?  I have tried adding headers
before and after where I open the file for HTTP/1.1 200 OK and the
corresponding headers.  I have also tried using a simple meta refresh, but
that doesn't work because it won't refresh until the page is entirely
loaded.

I am at a loss, I can't seem to find answer when I google it either.  Maybe
I'm just missing something.  I don't know.

Josh

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



[PHP] file download using header

2004-01-23 Thread Joshua Minnie
I am having some trouble making it possible to download a file using the
header function.  The problems are: (1) I get the dialog box to download the
file, but for some reason the type of file isn't getting passed to the box,
and (2) when I download a 4MB file it only seems to be getting 16.6KB.

I haven't used header for this purpose before this, so maybe I am missing
something.  I Googled around and found the content-disposition type I
thought I needed, I actually tried 3 different types (the file is a
compressed zip file).  I Googled around for tutorials on downloading files
and still haven't found the answer to correcting my problem.  Here is the
code I am using, maybe a couple more trained eyes looking at this could help
me out.

?php
$download = 'http://www.usa-financial.com'.urldecode( $_GET['link'] );
$type = urldecode( $_GET['type'] );
$size = filesize( '/home2/www/usa-financial'.urldecode(
$_GET['link'] ) );
header(Content-type: $type);
header(Content-Disposition: attachment; filename=$download;);
header(Accept-Ranges: bytes);
header(Content-Length: $size);

echo !-- $type \n $size \n $download \n --\n;
?

Josh

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



[PHP] Re: file download using header

2004-01-23 Thread Joshua Minnie
Okay, I found a solution to part one of my questions by changing my headers,
but for some reason I am still getting a fractional download of the file.
Most commonly it's about 16.6KB of a 4MB file. The kicker is it says that it
completed successfully.

Here is the modified code:
?php
$download = 'url/path/to/file'.urldecode( $_GET['link'] );
$type = urldecode( $_GET['type'] );
$size = filesize( '/abs/path/to/file'.urldecode( $_GET['link'] ) );
header(Pragma: public);
header(Expires: 0); // set expiration time
header(Cache-Control: must-revalidate, post-check=0, pre-check=0);
// browser must download file from server instead of cache
// force download dialog
header(Content-Type: application/force-download);
header(Content-Type: application/octet-stream);
header(Content-Type: application/download);
// use the Content-Disposition header to supply a recommended filename
and
// force the browser to display the save dialog.
header(Content-Disposition: attachment;
filename=.basename($download).;);
/*
The Content-transfer-encoding header should be binary, since the file
will be read
directly from the disk and the raw bytes passed to the downloading
computer.
The Content-length header is useful to set for downloads. The browser
will be able to
show a progress meter as a file downloads. The content-lenght can be
determines by
filesize function returns the size of a file.
*/
header(Content-Transfer-Encoding: binary);
header(Content-Length: .(string)($size));
readfile($download);
?

 I am having some trouble making it possible to download a file using the
 header function.  The problems are: (1) I get the dialog box to download
the
 file, but for some reason the type of file isn't getting passed to the
box,
 and (2) when I download a 4MB file it only seems to be getting 16.6KB.

 I haven't used header for this purpose before this, so maybe I am missing
 something.  I Googled around and found the content-disposition type I
 thought I needed, I actually tried 3 different types (the file is a
 compressed zip file).  I Googled around for tutorials on downloading files
 and still haven't found the answer to correcting my problem.  Here is the
 code I am using, maybe a couple more trained eyes looking at this could
help
 me out.

 ?php
 $download = 'http://www.usa-financial.com'.urldecode( $_GET['link'] );
 $type = urldecode( $_GET['type'] );
 $size = filesize( '/home2/www/usa-financial'.urldecode(
 $_GET['link'] ) );
 header(Content-type: $type);
 header(Content-Disposition: attachment; filename=$download;);
 header(Accept-Ranges: bytes);
 header(Content-Length: $size);

 echo !-- $type \n $size \n $download \n --\n;
 ?

 Josh

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



[PHP] Re: file download using header (SOLVED)

2004-01-23 Thread Joshua Minnie
I found the solution, I ended up instead of using readfile, use fopen and
fpassthru.  Here is the code that solved the problem

?php
$pathtofile = '/abs/path/to/file'.urldecode( $_GET['link'] );
$download = 'url/path/to/fille'.urldecode( $_GET['link'] );
$type = urldecode( $_GET['type'] );
$size = filesize( $pathtofile );
header(Pragma: private);
header(Expires: 0); // set expiration time
header(Cache-Control: must-revalidate, post-check=0, pre-check=0);
// browser must download file from server instead of cache

// force download dialog
header(Content-Type: application/force-download);
header(Content-Type: application/octet-stream);
header(Content-Type: application/download);
header(Content-Type: $type);

// use the Content-Disposition header to supply a recommended filename
and
// force the browser to display the save dialog.
header(Content-Disposition: attachment;
filename=.basename($download).;);

/*
The Content-transfer-encoding header should be binary, since the file
will be read
directly from the disk and the raw bytes passed to the downloading
computer.
The Content-length header is useful to set for downloads. The browser
will be able to
show a progress meter as a file downloads. The content-lenght can be
determines by
filesize function returns the size of a file.
*/
header(Content-Transfer-Encoding: binary);
header(Accept-Ranges: bytes);
header(Content-Length: $size);

$fh = fopen( $pathtofile , r);
fpassthru($fh);
?
 Okay, I found a solution to part one of my questions by changing my
headers,
 but for some reason I am still getting a fractional download of the file.
 Most commonly it's about 16.6KB of a 4MB file. The kicker is it says that
it
 completed successfully.

 Here is the modified code:
 ?php
 $download = 'url/path/to/file'.urldecode( $_GET['link'] );
 $type = urldecode( $_GET['type'] );
 $size = filesize( '/abs/path/to/file'.urldecode( $_GET['link'] ) );
 header(Pragma: public);
 header(Expires: 0); // set expiration time
 header(Cache-Control: must-revalidate, post-check=0, pre-check=0);
 // browser must download file from server instead of cache
 // force download dialog
 header(Content-Type: application/force-download);
 header(Content-Type: application/octet-stream);
 header(Content-Type: application/download);
 // use the Content-Disposition header to supply a recommended filename
 and
 // force the browser to display the save dialog.
 header(Content-Disposition: attachment;
 filename=.basename($download).;);
 /*
 The Content-transfer-encoding header should be binary, since the file
 will be read
 directly from the disk and the raw bytes passed to the downloading
 computer.
 The Content-length header is useful to set for downloads. The browser
 will be able to
 show a progress meter as a file downloads. The content-lenght can be
 determines by
 filesize function returns the size of a file.
 */
 header(Content-Transfer-Encoding: binary);
 header(Content-Length: .(string)($size));
 readfile($download);
 ?

  I am having some trouble making it possible to download a file using the
  header function.  The problems are: (1) I get the dialog box to download
 the
  file, but for some reason the type of file isn't getting passed to the
 box,
  and (2) when I download a 4MB file it only seems to be getting 16.6KB.
 
  I haven't used header for this purpose before this, so maybe I am
missing
  something.  I Googled around and found the content-disposition type I
  thought I needed, I actually tried 3 different types (the file is a
  compressed zip file).  I Googled around for tutorials on downloading
files
  and still haven't found the answer to correcting my problem.  Here is
the
  code I am using, maybe a couple more trained eyes looking at this could
 help
  me out.
 
  ?php
  $download = 'http://www.usa-financial.com'.urldecode(
$_GET['link'] );
  $type = urldecode( $_GET['type'] );
  $size = filesize( '/home2/www/usa-financial'.urldecode(
  $_GET['link'] ) );
  header(Content-type: $type);
  header(Content-Disposition: attachment; filename=$download;);
  header(Accept-Ranges: bytes);
  header(Content-Length: $size);
 
  echo !-- $type \n $size \n $download \n --\n;
  ?
 
  Josh

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



Re: [PHP] cache control with javascript

2003-10-21 Thread Joshua Minnie
The it that you were asking about was the server.  The javascript file is
actually a PHP file that produces the JavaScript that I need.  I only have
one access to a database and a while loop to generate the code.  Here is the
code pieces:

[code]
// already connected to the db
$sql = SELECT * FROM Customers ORDER BY LastName ASC, FirstName ASC;
$result = mysql_query($sql) or die(mysql_error());

while($row = mysql_fetch_assoc($result)) {
// generate the javascript
}
[/code]

The customer database can get potentially large so that this file could take
a while to generate.  Currently there are only 300 records but I anticipate
many more.  Does anyone have any recommendations that might speed this up?

Josh

- Edwin - [EMAIL PROTECTED] wrote:
  Does anybody know how I can make force a javascript file (written in
  PHP) to be cached if the user agent allows it?
 
  Here is the situation:
  I am creating a dropdown menu system that contains a customer list,
  loaded from a database.  This list is written to the javascript file
  for the menu. The menu can be quite large as the data grows.  What I
  would like to do, is force it to be cached (unless of course the
  user agent doesn't allow it) so that it doesn't have to make the
  call to generate the file each time.

 What is the second it in the last sentence above? A browser wouldn't
 make the call to generate the javascript file each time.

  I have searched through the php.net website and even through the
  HTTP/1.1 protocols.  I am continuing to look, but have not found a
  definite answer as to whether or not what I am trying to do is
  possible.

 Just make sure that the javascript is on a separate file (i.e.
 whatever.js) and that it's NOT being generated by your (php) script
 each time. Then, call that file from inside your html/php page.

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



RE: [PHP] cache control with javascript

2003-10-21 Thread Joshua Minnie
That really helped, I didn't think about generating the file that way.  I
have done other things like that, but sometimes it just helps when you get
another set of eyes on the project at hand.  Thanks for the refresher.

Josh

-Original Message-
From: - Edwin - [mailto:[EMAIL PROTECTED]
Sent: Tuesday, October 21, 2003 11:56 AM
To: Joshua Minnie
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP] cache control with javascript



On 2003.10.21, at 22:28 Asia/Tokyo, Joshua Minnie wrote:

 The it that you were asking about was the server.  The javascript
 file is
 actually a PHP file that produces the JavaScript that I need.  I only
 have
 one access to a database and a while loop to generate the code.  Here
 is the
 code pieces:

...[snipped_code]...

 The customer database can get potentially large so that this file
 could take
 a while to generate.  Currently there are only 300 records but I
 anticipate
 many more.  Does anyone have any recommendations that might speed this
 up?

Hmm... I think you missed the point earlier.

Here's the basic idea. Create/generate a separate file (whatever.js)
[1] and make sure that this file is ONLY *updated* when necessary (e.g.
updated database)[2]. Call this file inside your HTML head tags. [3]
This way, the whatever.js will be cached whenever possible.

- E -

[1] Check the file functions in the manual (if you're not familiar with
it already).
 (http://www.php.net/manual/en/ref.filesystem.php)
[2] Tip: Have a separate php script that generates the whatever.js.
 Use/run this script ONLY after you made an update to your database.
[3] Something like this:
   head
 script src=/path/to/whatever.js language=javascript
type=text/javascript/script
   /head

__
Do You Yahoo!?
Yahoo! BB is Broadband by Yahoo!
http://bb.yahoo.co.jp/

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



[PHP] cache control with javascript

2003-10-20 Thread Joshua Minnie
Does anybody know how I can make force a javascript file (written in PHP) to
be cached if the user agent allows it?

Here is the situation:
I am creating a dropdown menu system that contains a customer list, loaded
from a database.  This list is written to the javascript file for the menu.
The menu can be quite large as the data grows.  What I would like to do, is
force it to be cached (unless of course the user agent doesn't allow it) so
that it doesn't have to make the call to generate the file each time.

I have searched through the php.net website and even through the HTTP/1.1
protocols.  I am continuing to look, but have not found a definite answer as
to whether or not what I am trying to do is possible.

-- 
Joshua Minnie
Lead Web Application Developer
Advantage Computer Services, LLC
www.advantagecomputerservices.com
[EMAIL PROTECTED]

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



[PHP] PHP hosting with remote MySQL access allowed

2003-07-10 Thread Joshua Minnie
I am in the process of developing a client side application that needs to
speak to our remote databases.  Does anybody know of a hosting solution that
would allow me to have remote access to a MySQL database?  I done some
googling and found a quite a few hosting companies, but none of them that I
have check have the information posted on their websites, so I had to submit
an email question to them.

Thanks

Josh Minnie
[EMAIL PROTECTED]


There are 3 kinds of people in the worlds; those who can count and those who
can't.



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



[PHP] SSL, PHP, MySQL

2002-12-13 Thread Joshua Minnie
Hi all,
I was wondering if anyone could direct me to some good tutorials on how
to utilize PHP to access a MySQL database behind SSL.  I have been searching
PHPBuilder.com, PHPClasses.org, and hotscripts.com, and I can't seem to find
any good tutorials for a beginner when it comes to SSL.  I do have a fairly
good working knowledge of PHP and MySQL so I'm not necessarily looking for a
guide on that, I just need to know how to pass encrypted data back and
forth.  Here is the scenario:

My client has a website in which a customer will be purchasing gift
certificates online.  They don't need a comprehensive e-commerce package,
just simple information passed across a secure connection, such as: user
names, passwords, credit cards and mailing addresses.  We already have a
MySQL db set up with the gift certificate package information.  I just
need to be able to store the customer information for retrieval later by the
owners of the site.



Joshua Minnie
[EMAIL PROTECTED]
Independent Web Consultant / Developer
Wild Web Technology
www.wildwebtech.com

--
Server Information:
 + PHP v. 4.2.3
 + Apache 1.3.26
 + MySQL 3.23.53
--



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




Re: [PHP] SSL, PHP, MySQL

2002-12-13 Thread Joshua Minnie

What about utilizing an encrypted text file then.  Would there be anything
wrong with doing it that way?  I really don't have too much of an option as
far as the server specs go because I didn't set up the web hosting.

-Josh

Brad Bonkoski wrote:
 I think you may need to read:
 http://www.php.net/manual/en/function.mysql-connect.php

 It appears that the SSL client flag for connecting to MYSQL is not
available
 until 4.3.0, but you can pick up the 4.3.0RC3 version now, and test it
out!  I
 _think_ this is what you are looking for.
 HTH
 -Brad

 Joshua Minnie wrote:

  Hi all,
  I was wondering if anyone could direct me to some good tutorials on
how
  to utilize PHP to access a MySQL database behind SSL.  I have been
searching
  PHPBuilder.com, PHPClasses.org, and hotscripts.com, and I can't seem to
find
  any good tutorials for a beginner when it comes to SSL.  I do have a
fairly
  good working knowledge of PHP and MySQL so I'm not necessarily looking
for a
  guide on that, I just need to know how to pass encrypted data back and
  forth.  Here is the scenario:
 
  My client has a website in which a customer will be purchasing gift
  certificates online.  They don't need a comprehensive e-commerce
package,
  just simple information passed across a secure connection, such as: user
  names, passwords, credit cards and mailing addresses.  We already have a
  MySQL db set up with the gift certificate package information.  I just
  need to be able to store the customer information for retrieval later by
the
  owners of the site.
 
  Joshua Minnie
  [EMAIL PROTECTED]
  Independent Web Consultant / Developer
  Wild Web Technology
  www.wildwebtech.com
 
  --
  Server Information:
   + PHP v. 4.2.3
   + Apache 1.3.26
   + MySQL 3.23.53
  --



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




Re: [PHP] SSL, PHP, MySQL

2002-12-13 Thread Joshua Minnie
I will try on the PHP-DB newsgroup as well, but I wanted to let you know
about a link I found which shows the integration of SSL with MySQL and PHP.
Here is the link:
http://www.devshed.com/Server_Side/PHP/SoothinglySeamless/page1.html.
Thanks for the help.

-Josh

Brad Bonkoski [EMAIL PROTECTED] wrote:
 I would say it really all depends on your network configuration.  I am
assuming
 that your Web server running PHP is running on one machine (SERVER A)and
the
 MYSQL server running on another (SERVER B)outside of a common firewall?
Is this
 accurate?

 If this is true, then I would presume that PHP on SERVER A could encrypt a
 datafile with MYSQL instructions and send it securely to SERVER B, but
then who
 would un-encrypt it and feed it to MYSQL?

 You might want to look into other alternative like tunneling with SSH or
 'stunnel'.  I remember hearing some about it, but have not real experience
with
 it.  do a search on some MYSQL mailing lists for some insight.  Or ask on
the
 PHP-DB mailing list and you may be able to target a better qualified
audience.

 -Brad

 Joshua Minnie wrote:

  What about utilizing an encrypted text file then.  Would there be
anything
  wrong with doing it that way?  I really don't have too much of an option
as
  far as the server specs go because I didn't set up the web hosting.
 
  -Josh
 
  Brad Bonkoski wrote:
   I think you may need to read:
   http://www.php.net/manual/en/function.mysql-connect.php
  
   It appears that the SSL client flag for connecting to MYSQL is not
  available
   until 4.3.0, but you can pick up the 4.3.0RC3 version now, and test it
  out!  I
   _think_ this is what you are looking for.
   HTH
   -Brad
  
   Joshua Minnie wrote:
  
Hi all,
I was wondering if anyone could direct me to some good tutorials
on
  how
to utilize PHP to access a MySQL database behind SSL.  I have been
  searching
PHPBuilder.com, PHPClasses.org, and hotscripts.com, and I can't seem
to
  find
any good tutorials for a beginner when it comes to SSL.  I do have a
  fairly
good working knowledge of PHP and MySQL so I'm not necessarily
looking
  for a
guide on that, I just need to know how to pass encrypted data back
and
forth.  Here is the scenario:
   
My client has a website in which a customer will be purchasing gift
certificates online.  They don't need a comprehensive e-commerce
  package,
just simple information passed across a secure connection, such as:
user
names, passwords, credit cards and mailing addresses.  We already
have a
MySQL db set up with the gift certificate package information.  I
just
need to be able to store the customer information for retrieval
later by
  the
owners of the site.



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