Re: [PHP] Not using cached version

2006-08-30 Thread Curt Zirzow

On 8/30/06, Stut <[EMAIL PROTECTED]> wrote:

Peter Lauri wrote:
> I have some images stored in a database (only file name and other relevant
> information, rest stored in file system).
>
> I use the following html to access them:
>
> 
>
> At some pages I have the same image, so that tag will be seen on multiple
> places on the same page. So what I am curious is why all of the different
> images are loaded separately, instead of just recognizing that they are the
> same and use a cache version?
>
> This is the code that do all the work:
>
>   Header ("Content-type: $image_type");
>   readfile("files/$image");
>
> I am a little bit lost here; kick me in the right direction if you can :)
>

Probably because the browser sees the ? in the URL, thinks dynamic and
doesn't cache the result. You can set caching headers to get around this


You also have to remember that php by default sends the headers to
prevent caching, take a look at the headers responded via a static
.jpg file and a php page tha sends an image; You'll notice all those
extra no-cache type headers that enforce any browser to not reload a
(local) cached version of the file.

To get best performance
 support a HEAD request:
   send last-modified: and content-length: with the orignal sending
of the file and within your php script if the client requests a
IF_MODIFIED_SINCE header check the header against the value, if it
matches respond with something like:
  header('HTTP/1.0 304 Not modified');
  exit;

 support partial requests:
  check for the http header for partial content requests (I forget
the name, perhaps someone can remind me of it) and respond according
to the http specs.

HTH,
Curt.


(Google for it), or if you want *all* browsers to do it right, even the
poorly implemented ones, you could modify the URL so it doesn't have the
?. I do this using the Apache MultiViews option and a URL similar to
/image/123.gif. That actually runs /image.php which pulls the
REQUEST_URI server variable apart to get the required image. Do both and
you should be good for all browsers.

-Stut

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




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



Re: [PHP] send a file or stream

2006-08-30 Thread Curt Zirzow

On 8/29/06, Rafael Mora <[EMAIL PROTECTED]> wrote:

Hi!

i want to send a file or output stream in a .php, but first compress it, I
tryed the example to compress files but how do i do to send as answer to the
http request??


Unlike my recent posts, this could be a candidate for using ob_*

There is no need to compress it first, just use ob_start('ob_gzhandler');

if the client supports a compression method, no special things are
needed and the content sent is compressed otherwise it is sent without
compression.

see http://php.net/ob-gzhandler for more info.

HTH,
Curt.

Curt.

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



Re: [PHP] Strange situation when saving a file

2006-08-30 Thread Curt Zirzow

Please remove your 'this message is for the sole use of the person...'
thing or simply use a different account to ask questions..

On 8/29/06, Miguel Guirao <[EMAIL PROTECTED]> wrote:



Hi all,

I'm using ob_start() in order to save the content of a web page into a
variable string and then save it into a file in the file system. Every thing
is done OK. The only workaround I'm doing is adding a .doc file extension
when saving the file, in order to open the file in Word.


So you are adding a .doc extension so word can render the html file as
a wor doccument?



Once the file has been created and saved as I doc file (not a doc format!),
I e-mail it!

When the client gets the e-mail, he/she should open the file either by
saving the file to the local system or openning the file directly from the
e-mail attachment. Either way, I got a blank page in Word. If I open the
document directly from the web server, without having it sent by e-mail, it
opens correctly in Word. The only problem is when the file is been
emailed!!!


what you want to do is send the file you saved to a file as an
attatchment, if you are already doing so the problem is with how you
are composing the email that is sent to the client.

You are dealing with many issues, where the problem exists depends on
a lot of issues.

[snip]

Este mensaje es exclusivamente para el uso de la persona o entidad a quien esta 
dirigido;

[/snip]

again, do avoid using accounts that use this

Curt.

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



[PHP] RSS Creator

2006-08-30 Thread John Taylor-Johnston
Has anyone created an RSS feed creator in PHP? I could make one fast 
enough, but ...

John

--
John Taylor-Johnston
-
"If it's not Open Source, it's Murphy's Law."

'''Cégep de Sherbrooke:
ô¿ôhttp://www.cegepsherbrooke.qc.ca/languesmodernes/
 - 819-569-2064

 °v°   Bibliography of Comparative Studies in Canadian, Québec and Foreign 
Literatures
/(_)\  Université de Sherbrooke
 ^ ^   http://compcanlit.ca/ T: 819.569.2064

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



Re: [PHP] Free Shopping Carts

2006-08-30 Thread Curt Zirzow

On 8/30/06, Jay Blanchard <[EMAIL PROTECTED]> wrote:

[snip]
Are there free shopping carts that would work with

PHP 5.0.X + and MySQL 4.1.X + and /or PostgresQL 8.1+ ?
[/snip]


Yes.


Just in case:

Try google: 'php mysql shopping' cart or
'php pgsql shopping cart'

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



Re: [PHP] php generated javascript

2006-08-30 Thread Curt Zirzow

On 8/30/06, Shu Hung (Koala) <[EMAIL PROTECTED]> wrote:

On 8/31/06, Peter Lauri <[EMAIL PROTECTED]> wrote:
>
> Koala,
>
> There is no difference with the php generated javascript and javascript on
> a
> static html page.
>
> Take a look at the source code of the page that has been generated in the
> browser, and if that one looks as it should, it is probably your
> javascript
> that is not doing what it should :)
>
> And if that is the case you can join the [EMAIL PROTECTED] list for
> that
> purpose.
>
> /Peter
>
>
Petar,

Thanks for your reply.

I've used some server side cache for that javascript generation now.
It works a lot better. Seems to me that it takes too long to generate
the javascript. Sometimes browsers decided to ignores the javascript
and just run.


You might want to be more elaborate than that... What is considered
longer, What do you mean it ignores the javascript?


I used "document.write" in that javascript. When it isn't loaded
completely, nothing shows. I wonder if there is any better way.


This i dont understand, perhaps an example of what you are doing?

Curt.

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



Re: [PHP] php generated javascript

2006-08-30 Thread J R

put this at the top of your script "ob_start();" or before any output.

On 8/31/06, Shu Hung (Koala) <[EMAIL PROTECTED]> wrote:


On 8/31/06, Peter Lauri <[EMAIL PROTECTED]> wrote:
>
> Koala,
>
> There is no difference with the php generated javascript and javascript
on
> a
> static html page.
>
> Take a look at the source code of the page that has been generated in
the
> browser, and if that one looks as it should, it is probably your
> javascript
> that is not doing what it should :)
>
> And if that is the case you can join the [EMAIL PROTECTED] list for
> that
> purpose.
>
> /Peter
>
>
Petar,

Thanks for your reply.

I've used some server side cache for that javascript generation now.
It works a lot better. Seems to me that it takes too long to generate
the javascript. Sometimes browsers decided to ignores the javascript
and just run.

I used "document.write" in that javascript. When it isn't loaded
completely, nothing shows. I wonder if there is any better way.


Koala





--
GMail Rocks!!!


Re: [PHP] php generated javascript

2006-08-30 Thread Shu Hung (Koala)

On 8/31/06, Peter Lauri <[EMAIL PROTECTED]> wrote:


Koala,

There is no difference with the php generated javascript and javascript on
a
static html page.

Take a look at the source code of the page that has been generated in the
browser, and if that one looks as it should, it is probably your
javascript
that is not doing what it should :)

And if that is the case you can join the [EMAIL PROTECTED] list for
that
purpose.

/Peter



Petar,

Thanks for your reply.

I've used some server side cache for that javascript generation now.
It works a lot better. Seems to me that it takes too long to generate
the javascript. Sometimes browsers decided to ignores the javascript
and just run.

I used "document.write" in that javascript. When it isn't loaded
completely, nothing shows. I wonder if there is any better way.


Koala


RE: [PHP] php generated javascript

2006-08-30 Thread Peter Lauri
Koala,

There is no difference with the php generated javascript and javascript on a
static html page.

Take a look at the source code of the page that has been generated in the
browser, and if that one looks as it should, it is probably your javascript
that is not doing what it should :)

And if that is the case you can join the [EMAIL PROTECTED] list for that
purpose.

/Peter



-Original Message-
From: Shu Hung (Koala) [mailto:[EMAIL PROTECTED] 
Sent: Thursday, August 31, 2006 10:41 AM
To: PHP General Users
Subject: [PHP] php generated javascript

Hello,

I'm writing a script to generate a javascript. The javascript would
generate a banner when it is sourced. This javascript is sourced
by another html like this:



However, Sometimes the javascript doesn't show anything at all. it
seems that the php generated javascript cannot be loaded sometimes.
Maybe the generation takes too long. I'm not sure about that.

Is there anyway to deal with it?

Koala Yeung

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



[PHP] php generated javascript

2006-08-30 Thread Shu Hung (Koala)

Hello,

I'm writing a script to generate a javascript. The javascript would
generate a banner when it is sourced. This javascript is sourced
by another html like this:



However, Sometimes the javascript doesn't show anything at all. it
seems that the php generated javascript cannot be loaded sometimes.
Maybe the generation takes too long. I'm not sure about that.

Is there anyway to deal with it?

Koala Yeung


Re: [PHP] Strange situation when saving a file

2006-08-30 Thread Andrew Kreps

On 8/30/06, Miguel Guirao <[EMAIL PROTECTED]> wrote:

> Once the file has been created and saved as I doc file (not a doc
format!),
> I e-mail it!
>
> When the client gets the e-mail, he/she should open the file either by
> saving the file to the local system or openning the file directly from the
> e-mail attachment. Either way, I got a blank page in Word. If I open the
> document directly from the web server, without having it sent by e-mail,
it
> opens correctly in Word. The only problem is when the file is been
> emailed!!!


One problem could be the .doc extension.  A lot of email clients will
give you a warning at best, and at worst will completely remove the
attachment of things like Word documents, due to thier ability to
contain dangerous macros.  I don't think that is the problem you're
currently having, but it's good to be aware of.

Other than that, I would look at what add_attachment is actually doing
to see if it is indeed grabbing the correct file.

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



RE: [PHP] Free Shopping Carts

2006-08-30 Thread Jay Blanchard
[snip]
Are there free shopping carts that would work with 

PHP 5.0.X + and MySQL 4.1.X + and /or PostgresQL 8.1+ ?
[/snip]


Yes.





































You do have access to Google, right?

http://www.google.com/search?hl=en&lr=&q=free+open+source+shopping+cart+
php+5+mysql

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



[PHP] Free Shopping Carts

2006-08-30 Thread The Doctor
Are there free shopping carts that would work with 

PHP 5.0.X + and MySQL 4.1.X + and /or PostgresQL 8.1+ ?

-- 
Member - Liberal International  
This is [EMAIL PROTECTED]   Ici [EMAIL PROTECTED]
God Queen and country! Beware Anti-Christ rising!
New Brunswick kick out the Harper Puppet and VOTE LIBERAL on 18 Sept 2006

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



[PHP] globals, simpletest and php from command line

2006-08-30 Thread blackwater dev

I have a php app that runs on php4.  I am writing some unit tests now using
SimpleTest but some of the libraries that I have to pull in for testing are
failing.  For example, my db library sets some params:

$dname="mydatabase";
$usr="me";
..etc

I then have some mysql functions that connect using

function con(){
 global $dname;
 ..etc.

}

When this is all run from the browser, things are fine but via simpletest
and command line, the globals are lost.  Is this just a problem with the
command line or with simpletest?

Thanks.


RE: [PHP] send a file or stream

2006-08-30 Thread Peter Lauri
I think the stations.zip is empty... Try this:

Between your scripting and the readfile() put a sleep(2); between so it waits 2 
seconds before pushing the data.

And I also suggest:

while()
{
fwrite($da, "$somevar1:$somevar2");
}
fclose($da);

Header()

(try sleep(2); here)

readfile();


-Original Message-
From: Rafael Mora [mailto:[EMAIL PROTECTED] 
Sent: Thursday, August 31, 2006 1:25 AM
To: Peter Lauri
Cc: php-general
Subject: Re: [PHP] send a file or stream

I can download it, but when I see the file I downloaded has 0 bytes, and I
have readfile("stations.zip");




On 8/30/06, Peter Lauri <[EMAIL PROTECTED]> wrote:
>
> But can you download it correctly? Is it just the download box that shows
> 0 bytes?
>
> Or is it so that you actually is doing what you do below readfile()
> without any argument? So that you are actually downloading something empty?
> :)
>
> /Peter
>
>
>
> -Original Message-
> From: Rafael Mora [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, August 30, 2006 8:00 PM
> To: php-general@lists.php.net
> Subject: Re: [PHP] send a file or stream
>
> Hi!!
>
> Well it works now, but with another issue, when I download it, it says
> that
> it size is 0 bytes!!
>
> i fwrite the file in a while, is it correct?
>
> header()...
> while()
> {
> fwrite($da, "$somevar1:$somevar2");
> }
> fclose($da);
>
> readfile();
>
> thanks
>
>
>
> On 8/30/06, Peter Lauri <[EMAIL PROTECTED]> wrote:
> >
> > Try this:
> >
> > header("Pragma: public");
> > header("Expires: 0"); // set expiration time
> > header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
> > header("Content-Type: application/octet-stream");
> > header('Content-Disposition: attachment; filename="stations.gzip"');
> > header("Content-Transfer-Encoding: binary");
> > header("Content-Length: ".filesize(stations.gzip));
> > readfile("stations.gzip");
> >
> > /Peter
> >
> > PS! To maintain the list and its functionality, do not post same message
> > multiple times  DS!
> >
> >
> > -Original Message-
> > From: Rafael Mora [mailto:[EMAIL PROTECTED]
> > Sent: Wednesday, August 30, 2006 11:01 AM
> > To: Peter Lauri
> > Cc: php-general@lists.php.net
> > Subject: Re: [PHP] send a file or stream
> >
> > Ok it works, but it returns me the same .php file, not the one I am
> > creating
> >
> >
> >
> > On 8/29/06, Peter Lauri <[EMAIL PROTECTED]> wrote:
> > >
> > > You need to make sure that you are not outputting ANYTHING before you
> do
> > > this. I might guess that you have a whitespace in the top of the
> script.
> > As
> > > soon as you output, the server can not send any more header
> information,
> > and
> > > the browser will think it is just text instead of treating it as an
> > > octet-stream.
> > >
> > >
> > >
> > > /Peter
> > >
> > >
> > >
> > > _
> > >
> > > From: Rafael Mora [mailto:[EMAIL PROTECTED]
> > > Sent: Wednesday, August 30, 2006 10:25 AM
> > > To: Peter Lauri
> > > Cc: php-general@lists.php.net
> > > Subject: Re: [PHP] send a file or stream
> > >
> > >
> > >
> > > I test it and gave me this: xœ ÉÈ,V¢D…'Ôâ=(r)(??/§C0/¿D!1O!3·
> > > ¿¨$1¯D¡¸¤(3/] LÖ‑ so the user should read that?? this is my code:
> > >
> > >
> > >
> > >  > > $params = array('level' => 6, 'window' => 15, 'memory' => 9);
> > >
> > > $texto_original = "This is a test.\nThis is only a test.\nThis is not
> an
> > > important string.\n";
> > > //echo "El texto original tiene " . strlen($texto_original) . "
> > > caracteres.\n";
> > >
> > > $da = fopen('stations.gzip', 'w');
> > > stream_filter_append($da, 'zlib.deflate', STREAM_FILTER_WRITE,
> $params);
> > > fwrite($da, $texto_original);
> > > fclose($da);
> > >
> > > header("Content-Type: application/octet-stream");
> > > readfile("stations.gzip");
> > >
> > >
> > >
> > >
> > >
> > > On 8/29/06, Peter Lauri <[EMAIL PROTECTED]> wrote:
> > >
> > >  > > header("Content-Type: application/octet-stream");
> > > readfile("path_to_compressed_file");
> > > ?>
> > >
> > >
> > >
> > > Should do it then. if you know the path to the file :)
> > >
> > >
> > >
> > > _
> > >
> > > From: Rafael Mora [mailto:[EMAIL PROTECTED]
> > > Sent: Wednesday, August 30, 2006 10:10 AM
> > > To: Peter Lauri
> > > Subject: Re: [PHP] send a file or stream
> > >
> > >
> > >
> > > 1. A user sends a request to your server to get a compressed file
> > > 2. You compress the file on the server
> > > 3. I want to send back the file to the user
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > > On 8/29/06, Peter Lauri <[EMAIL PROTECTED]> wrote:
> > >
> > > Do you mean the following:
> > >
> > > 1. A user sends a request to your server to get a compressed file
> > > 2. You compress the file on the server
> > > 3. You want to send back to compressed file to the server
> > >
> > > It is number 3 you asking for?
> > >
> > > In that case:
> > >
> > >  > > header("Content-Type: application/octet-stream");
> > > readfile("path_to_compressed_file");
> > > ?>
> > >
> > > /Peter
> > >
> > >
> > > -Original Message-
> > > 

Re: [PHP] send a file or stream

2006-08-30 Thread Rafael Mora

I can download it, but when I see the file I downloaded has 0 bytes, and I
have readfile("stations.zip");




On 8/30/06, Peter Lauri <[EMAIL PROTECTED]> wrote:


But can you download it correctly? Is it just the download box that shows
0 bytes?

Or is it so that you actually is doing what you do below readfile()
without any argument? So that you are actually downloading something empty?
:)

/Peter



-Original Message-
From: Rafael Mora [mailto:[EMAIL PROTECTED]
Sent: Wednesday, August 30, 2006 8:00 PM
To: php-general@lists.php.net
Subject: Re: [PHP] send a file or stream

Hi!!

Well it works now, but with another issue, when I download it, it says
that
it size is 0 bytes!!

i fwrite the file in a while, is it correct?

header()...
while()
{
fwrite($da, "$somevar1:$somevar2");
}
fclose($da);

readfile();

thanks



On 8/30/06, Peter Lauri <[EMAIL PROTECTED]> wrote:
>
> Try this:
>
> header("Pragma: public");
> header("Expires: 0"); // set expiration time
> header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
> header("Content-Type: application/octet-stream");
> header('Content-Disposition: attachment; filename="stations.gzip"');
> header("Content-Transfer-Encoding: binary");
> header("Content-Length: ".filesize(stations.gzip));
> readfile("stations.gzip");
>
> /Peter
>
> PS! To maintain the list and its functionality, do not post same message
> multiple times  DS!
>
>
> -Original Message-
> From: Rafael Mora [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, August 30, 2006 11:01 AM
> To: Peter Lauri
> Cc: php-general@lists.php.net
> Subject: Re: [PHP] send a file or stream
>
> Ok it works, but it returns me the same .php file, not the one I am
> creating
>
>
>
> On 8/29/06, Peter Lauri <[EMAIL PROTECTED]> wrote:
> >
> > You need to make sure that you are not outputting ANYTHING before you
do
> > this. I might guess that you have a whitespace in the top of the
script.
> As
> > soon as you output, the server can not send any more header
information,
> and
> > the browser will think it is just text instead of treating it as an
> > octet-stream.
> >
> >
> >
> > /Peter
> >
> >
> >
> > _
> >
> > From: Rafael Mora [mailto:[EMAIL PROTECTED]
> > Sent: Wednesday, August 30, 2006 10:25 AM
> > To: Peter Lauri
> > Cc: php-general@lists.php.net
> > Subject: Re: [PHP] send a file or stream
> >
> >
> >
> > I test it and gave me this: xœ ÉÈ,V¢D…'Ôâ=(r)(??/§C0/¿D!1O!3·
> > ¿¨$1¯D¡¸¤(3/] LÖ‑ so the user should read that?? this is my code:
> >
> >
> >
> >  > $params = array('level' => 6, 'window' => 15, 'memory' => 9);
> >
> > $texto_original = "This is a test.\nThis is only a test.\nThis is not
an
> > important string.\n";
> > //echo "El texto original tiene " . strlen($texto_original) . "
> > caracteres.\n";
> >
> > $da = fopen('stations.gzip', 'w');
> > stream_filter_append($da, 'zlib.deflate', STREAM_FILTER_WRITE,
$params);
> > fwrite($da, $texto_original);
> > fclose($da);
> >
> > header("Content-Type: application/octet-stream");
> > readfile("stations.gzip");
> >
> >
> >
> >
> >
> > On 8/29/06, Peter Lauri <[EMAIL PROTECTED]> wrote:
> >
> >  > header("Content-Type: application/octet-stream");
> > readfile("path_to_compressed_file");
> > ?>
> >
> >
> >
> > Should do it then. if you know the path to the file :)
> >
> >
> >
> > _
> >
> > From: Rafael Mora [mailto:[EMAIL PROTECTED]
> > Sent: Wednesday, August 30, 2006 10:10 AM
> > To: Peter Lauri
> > Subject: Re: [PHP] send a file or stream
> >
> >
> >
> > 1. A user sends a request to your server to get a compressed file
> > 2. You compress the file on the server
> > 3. I want to send back the file to the user
> >
> >
> >
> >
> >
> >
> >
> > On 8/29/06, Peter Lauri <[EMAIL PROTECTED]> wrote:
> >
> > Do you mean the following:
> >
> > 1. A user sends a request to your server to get a compressed file
> > 2. You compress the file on the server
> > 3. You want to send back to compressed file to the server
> >
> > It is number 3 you asking for?
> >
> > In that case:
> >
> >  > header("Content-Type: application/octet-stream");
> > readfile("path_to_compressed_file");
> > ?>
> >
> > /Peter
> >
> >
> > -Original Message-
> > From: Rafael Mora [mailto:[EMAIL PROTECTED]
> > Sent: Wednesday, August 30, 2006 2:34 AM
> > To: php-general@lists.php.net
> > Subject: [PHP] send a file or stream
> >
> > Hi!
> >
> > i want to send a file or output stream in a .php, but first compress
it,
> I
> > tryed the example to compress files but how do i do to send as answer
to
> > the
> >
> > http request??
> >
> > Rafa
> >
> >
> >
> >
> >
> >
> >
> >
> >
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>




RE: [PHP] send a file or stream

2006-08-30 Thread Peter Lauri
But can you download it correctly? Is it just the download box that shows 0 
bytes?

Or is it so that you actually is doing what you do below readfile() without any 
argument? So that you are actually downloading something empty? :)

/Peter



-Original Message-
From: Rafael Mora [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, August 30, 2006 8:00 PM
To: php-general@lists.php.net
Subject: Re: [PHP] send a file or stream

Hi!!

Well it works now, but with another issue, when I download it, it says that
it size is 0 bytes!!

i fwrite the file in a while, is it correct?

header()...
while()
{
  fwrite($da, "$somevar1:$somevar2");
}
fclose($da);

readfile();

thanks



On 8/30/06, Peter Lauri <[EMAIL PROTECTED]> wrote:
>
> Try this:
>
> header("Pragma: public");
> header("Expires: 0"); // set expiration time
> header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
> header("Content-Type: application/octet-stream");
> header('Content-Disposition: attachment; filename="stations.gzip"');
> header("Content-Transfer-Encoding: binary");
> header("Content-Length: ".filesize(stations.gzip));
> readfile("stations.gzip");
>
> /Peter
>
> PS! To maintain the list and its functionality, do not post same message
> multiple times  DS!
>
>
> -Original Message-
> From: Rafael Mora [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, August 30, 2006 11:01 AM
> To: Peter Lauri
> Cc: php-general@lists.php.net
> Subject: Re: [PHP] send a file or stream
>
> Ok it works, but it returns me the same .php file, not the one I am
> creating
>
>
>
> On 8/29/06, Peter Lauri <[EMAIL PROTECTED]> wrote:
> >
> > You need to make sure that you are not outputting ANYTHING before you do
> > this. I might guess that you have a whitespace in the top of the script.
> As
> > soon as you output, the server can not send any more header information,
> and
> > the browser will think it is just text instead of treating it as an
> > octet-stream.
> >
> >
> >
> > /Peter
> >
> >
> >
> > _
> >
> > From: Rafael Mora [mailto:[EMAIL PROTECTED]
> > Sent: Wednesday, August 30, 2006 10:25 AM
> > To: Peter Lauri
> > Cc: php-general@lists.php.net
> > Subject: Re: [PHP] send a file or stream
> >
> >
> >
> > I test it and gave me this: xœ ÉÈ,V¢D…'Ôâ=(r)(??/§C0/¿D!1O!3·
> > ¿¨$1¯D¡¸¤(3/] LÖ‑ so the user should read that?? this is my code:
> >
> >
> >
> >  > $params = array('level' => 6, 'window' => 15, 'memory' => 9);
> >
> > $texto_original = "This is a test.\nThis is only a test.\nThis is not an
> > important string.\n";
> > //echo "El texto original tiene " . strlen($texto_original) . "
> > caracteres.\n";
> >
> > $da = fopen('stations.gzip', 'w');
> > stream_filter_append($da, 'zlib.deflate', STREAM_FILTER_WRITE, $params);
> > fwrite($da, $texto_original);
> > fclose($da);
> >
> > header("Content-Type: application/octet-stream");
> > readfile("stations.gzip");
> >
> >
> >
> >
> >
> > On 8/29/06, Peter Lauri <[EMAIL PROTECTED]> wrote:
> >
> >  > header("Content-Type: application/octet-stream");
> > readfile("path_to_compressed_file");
> > ?>
> >
> >
> >
> > Should do it then. if you know the path to the file :)
> >
> >
> >
> > _
> >
> > From: Rafael Mora [mailto:[EMAIL PROTECTED]
> > Sent: Wednesday, August 30, 2006 10:10 AM
> > To: Peter Lauri
> > Subject: Re: [PHP] send a file or stream
> >
> >
> >
> > 1. A user sends a request to your server to get a compressed file
> > 2. You compress the file on the server
> > 3. I want to send back the file to the user
> >
> >
> >
> >
> >
> >
> >
> > On 8/29/06, Peter Lauri <[EMAIL PROTECTED]> wrote:
> >
> > Do you mean the following:
> >
> > 1. A user sends a request to your server to get a compressed file
> > 2. You compress the file on the server
> > 3. You want to send back to compressed file to the server
> >
> > It is number 3 you asking for?
> >
> > In that case:
> >
> >  > header("Content-Type: application/octet-stream");
> > readfile("path_to_compressed_file");
> > ?>
> >
> > /Peter
> >
> >
> > -Original Message-
> > From: Rafael Mora [mailto:[EMAIL PROTECTED]
> > Sent: Wednesday, August 30, 2006 2:34 AM
> > To: php-general@lists.php.net
> > Subject: [PHP] send a file or stream
> >
> > Hi!
> >
> > i want to send a file or output stream in a .php, but first compress it,
> I
> > tryed the example to compress files but how do i do to send as answer to
> > the
> >
> > http request??
> >
> > Rafa
> >
> >
> >
> >
> >
> >
> >
> >
> >
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

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



Re: [PHP] Strange situation when saving a file

2006-08-30 Thread Stut

Miguel Guirao wrote:

include("evm_mailer.php"); //The class I'm using for sending e-mails, from
www.phpclasses.org

ob_start(); // Start Output Buffer functionality


//**

function sendcorreo($from,$doc,$depto,$cuerpo){
$simple_mailer = new EVM_Mailer(); // create new EVM_Mailer object
$simple_mailer->set_sender("Departamento de Logística On-line
R8","[EMAIL PROTECTED]"); // set sender name and email address
$simple_mailer->set_subject("E-mail subject"); // set the subject line 
of
the email
$simple_mailer->set_message_type("html"); // text or html mime-type
$simple_mailer->set_message($cuerpo); // set the message body of the 
email
message
$simple_mailer->add_recipient("Recipient","[EMAIL PROTECTED]"); // add a
recipient to the email To: list
$simple_mailer->add_CC($depto,$from);
$simple_mailer->add_BCC("CC Name","[EMAIL PROTECTED]"); // add a 
recipient
to the email BCC: list
$simple_mailer->add_attachment($doc,"/path/to/my/file","html"); // add 
the
file as an attachment
if($depto=="CENTRAL"){
$simple_mailer->add_CC("CC2 Name","[EMAIL PROTECTED]"); // add 
a recipient
to the email CC: list
}
$simple_mailer->send(); // send the email
}

//**
**



  


I'm not at all familiar with the class you're using to send the email, 
but what is the third parameter to add_attachment? You're setting it to 
html, is that right? What email client are you checking the email with? 
Does it allow you to view the raw email? Does it look right? If all else 
fails I think your best bet is to contact the author of the class.


-Stut

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



Re: [PHP] substr and UTF-8

2006-08-30 Thread Michael B Allen
On Wed, 30 Aug 2006 21:46:18 +0700
"Peter Lauri" <[EMAIL PROTECTED]> wrote:

>   function is_utf8_start($b) {
>   return (($b & 0x80) == 0) || ($b & 0x40);
>   }
> [/snip]
> 
> :) I think I will go with the mb_substr function, it works for me :)

Yeah, I guess that's the right thing to do. Otherwise, in a year you
won't remember what the cryptic masking is all about.

Mike

-- 
Michael B Allen
PHP Active Directory SSO
http://www.ioplex.com/

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



Re: [PHP] what's all the about then?

2006-08-30 Thread tedd

At 4:34 PM +0200 8/30/06, Jochem Maas wrote:

tedd wrote:

 At 2:19 PM +0200 8/30/06, Paul Scott wrote:

 On Wed, 2006-08-30 at 13:10 +0100, Ross wrote:

  (ii) what is the technique called


 Read up on MVC (Model View Controller) and the front end controller
 design pattern.

 Wikipedia is a good start.

 --Paul


 Interesting that someone finally put a name to something we've been
 doing for decades. We used to just call it input, process, and display,
 which to me seems simpler. In addition, if one used IPD, it's acronym
 would at least be in the right order.


seems whenever I write something that resembles a FrontController I end up
with a process() and a display() method ... small world.



No, it's just that these organizational problems have been around 
since the days of rock programming -- that's what "Design Patterns" 
are, namely trying to identify, organize, and reuse code. That's 
something else we've been doing for decades that has a brand new name.


There's a surprisingly number of old techniques that have been given 
a new coat of paint and sold as the latest model. The key is to 
recognize them, perhaps I should coin a new name for that, maybe 
"Concept Evolution", "Process Inheritance", or "Legacy 
Identification" -- but, to really get it accepted, it has to be 
complicated enough to impress.  :-)


tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



RE: [PHP] Strange situation when saving a file

2006-08-30 Thread Miguel Guirao


OK, here is the code behind my problem:

include("evm_mailer.php"); //The class I'm using for sending e-mails, from
www.phpclasses.org

ob_start(); // Start Output Buffer functionality


//**

function sendcorreo($from,$doc,$depto,$cuerpo){
$simple_mailer = new EVM_Mailer(); // create new EVM_Mailer object
$simple_mailer->set_sender("Departamento de Logística On-line
R8","[EMAIL PROTECTED]"); // set sender name and email address
$simple_mailer->set_subject("E-mail subject"); // set the subject line 
of
the email
$simple_mailer->set_message_type("html"); // text or html mime-type
$simple_mailer->set_message($cuerpo); // set the message body of the 
email
message
$simple_mailer->add_recipient("Recipient","[EMAIL PROTECTED]"); // add a
recipient to the email To: list
$simple_mailer->add_CC($depto,$from);
$simple_mailer->add_BCC("CC Name","[EMAIL PROTECTED]"); // add a 
recipient
to the email BCC: list
$simple_mailer->add_attachment($doc,"/path/to/my/file","html"); // add 
the
file as an attachment
if($depto=="CENTRAL"){
$simple_mailer->add_CC("CC2 Name","[EMAIL PROTECTED]"); // add 
a recipient
to the email CC: list
}
$simple_mailer->send(); // send the email
}

//**
**




-Original Message-
From: Stut [mailto:[EMAIL PROTECTED]
Sent: Miércoles, 30 de Agosto de 2006 03:16 a.m.
To: Miguel Guirao
Cc: PHP List
Subject: Re: [PHP] Strange situation when saving a file


Miguel Guirao wrote:
> I'm using ob_start() in order to save the content of a web page into a
> variable string and then save it into a file in the file system. Every
thing
> is done OK. The only workaround I'm doing is adding a .doc file extension
> when saving the file, in order to open the file in Word.
>
> Once the file has been created and saved as I doc file (not a doc
format!),
> I e-mail it!
>
> When the client gets the e-mail, he/she should open the file either by
> saving the file to the local system or openning the file directly from the
> e-mail attachment. Either way, I got a blank page in Word. If I open the
> document directly from the web server, without having it sent by e-mail,
it
> opens correctly in Word. The only problem is when the file is been
> emailed!!!
>
>
> What could be going wrong?? Any ideas??
>

My crystal ball tells me that there's something wrong with your code.
Unfortunately, due to the lead shield that surrounds all PHP code I
cannot see it from here. I suggest your next step would be to remove
said shield by emailing the relevant parts to the list. Then we may be
able to bring our collective skills together to assist in solving your
problem.

-Stut


Este mensaje es exclusivamente para el uso de la persona o entidad a quien esta 
dirigido; contiene informacion estrictamente confidencial y legalmente 
protegida, cuya divulgacion es sancionada por la ley. Si el lector de este 
mensaje no es a quien esta dirigido, ni se trata del empleado o agente 
responsable de esta informacion, se le notifica por medio del presente, que su 
reproduccion y distribucion, esta estrictamente prohibida. Si Usted recibio 
este comunicado por error, favor de notificarlo inmediatamente al remitente y 
destruir el mensaje. Todas las opiniones contenidas en este mail son propias 
del autor del mensaje y no necesariamente coinciden con las de Radiomovil 
Dipsa, S.A. de C.V. o alguna de sus empresas controladas, controladoras, 
afiliadas y subsidiarias. Este mensaje intencionalmente no contiene acentos.

This message is for the sole use of the person or entity to whom it is being 
sent.  Therefore, it contains strictly confidential and legally protected 
material whose disclosure is subject to penalty by law.  If the person reading 
this message is not the one to whom it is being sent and/or is not an employee 
or the responsible agent for this information, this person is herein notified 
that any unauthorized dissemination, distribution or copying of the materials 
included in this facsimile is strictly prohibited.  If you received this 
document by mistake please notify  immediately to the subscriber and destroy 
the message. Any opinions contained in this e-mail are those of the author of 
the message and do not necessarily coincide with those of Radiomovil Dipsa, 
S.A. de C.V. or any of its control, controlled, affiliates and subsidiaries 
companies. No part of this message or attachments may be used or reproduced in 
any manner whatsoever.

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



Re: [PHP] Check for unsafe HTML

2006-08-30 Thread Bogdan Ribic




we have a 'Matt' that's actually a 'Dave' (or is it the other way around),
now we have a 'Bogdan' who is propably a 'Boban'.
Im sure there are other examples.

Seems we attract multiple personality disorder cases around here.



Good catch :)

Boban is my nickname that everybody calls me, Bogdan is written in all 
documents.


as for RTFM, I was looking for a way to strip javascript tags etc while 
leaving everything else in place. I knew about strip_tags. I found a 
class later that does the job (look at my other posting in this thread)


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



Re: [PHP] Check for unsafe HTML

2006-08-30 Thread Bogdan Ribic




do, not try.


http://us3.php.net/strip_tags

tedd


Thanx, you've been lots of help :) But I wanted to clean out unwanted 
tags, not all of them. I found this class:


http://phpclasses.waaf.net/browse/package/2189.html

that is supposed to do the job, in case someone else has same problem.

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



Re: [PHP] Query result column to array

2006-08-30 Thread Rafael Mora

Hi!!

What I do is just this:

$_ar = array();


  while($_field = mysql_fetch_row($_result))
  {$_aloft["$_field[0]"] = "$_field[1]";}

  while(list($_key,$_val) = each($_ar))


On 8/30/06, Christopher Watson <[EMAIL PROTECTED]> wrote:


I'm looking for a native method for taking all of the values from one
column of a query result and creating an array of those values.
Procedurally, I'd tend to want to do this:

query("SELECT my_id FROM my_table");
while ($row = $query_result->fetchRow())
   $my_id_array[] = $row['my_id'];
?>

Heck, ColdFusion has the ValueList function which does exactly what I
want (of course, it returns a delimited list [string], not a native
array, but the one-step method is there).  Is there anything in
PHP-land that does that?  Or am I pretty much stuck using some
variation of the code above?

Christopher Watson
Principal Architect
The International Variable Star Index (VSX)
http://vsx.aavso.org

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




RE: [PHP] substr and UTF-8

2006-08-30 Thread Peter Lauri
[snip]
Actually this is false. I don't know what I was thinking. The high bit
will be set in all bytes of a UTF-8 byte sequence. If it's not it's an
ASCII character.

The bytes are actually layed out as follows [1]:

U- ___ U-007F:  0xxx
U-0080 ___ U-07FF:  110x 10xx
U-0800 ___ U-:  1110 10xx 10xx
U-0001 ___ U-001F:  0xxx 10xx 10xx 10xx

So there's no way to tell the last byte of a UTF-8 byte sequence but you
can tell if it's the first byt looking at bits 7 and 8. Specifically,
if bit 8 is not on, the character is ASCII and thus the "start" of a
new character. Otherwise, if bit 7 is on it's the start of a new UTF-8
byte sequence.

  function is_utf8_start($b) {
  return (($b & 0x80) == 0) || ($b & 0x40);
  }
[/snip]

:) I think I will go with the mb_substr function, it works for me :)

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



Re: [PHP] Check for unsafe HTML

2006-08-30 Thread Jochem Maas
tedd wrote:
> At 4:12 PM +0200 8/30/06, Bogdan Ribic wrote:
>> Hi all,
>>
>>   I need to check html that is entered by user for unsafe content (ie
>> javascript, vbscript, onmouseover etc) and still keep "safe" tags. Is
>> there any easy way for that?
>>
>> Boban.
> 
> 
> Try strip_tags().

do, not try.

> 
> http://us3.php.net/strip_tags
> 
> tedd

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



Re: [PHP] Check for unsafe HTML

2006-08-30 Thread Jochem Maas
Bogdan Ribic wrote:
> Hi all,
> 
>   I need to check html that is entered by user for unsafe content (ie
> javascript, vbscript, onmouseover etc) and still keep "safe" tags. Is
> there any easy way for that?

PRTFM: http://php.net/striptags

> 
> Boban.

we have a 'Matt' that's actually a 'Dave' (or is it the other way around),
now we have a 'Bogdan' who is propably a 'Boban'.
Im sure there are other examples.

Seems we attract multiple personality disorder cases around here.

> 

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



Re: [PHP] Check for unsafe HTML

2006-08-30 Thread tedd

At 4:12 PM +0200 8/30/06, Bogdan Ribic wrote:

Hi all,

  I need to check html that is entered by user for unsafe content 
(ie javascript, vbscript, onmouseover etc) and still keep "safe" 
tags. Is there any easy way for that?


Boban.



Try strip_tags().

http://us3.php.net/strip_tags

tedd
--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



[PHP] Query result column to array

2006-08-30 Thread Christopher Watson

I'm looking for a native method for taking all of the values from one
column of a query result and creating an array of those values.
Procedurally, I'd tend to want to do this:

query("SELECT my_id FROM my_table");
while ($row = $query_result->fetchRow())
   $my_id_array[] = $row['my_id'];
?>

Heck, ColdFusion has the ValueList function which does exactly what I
want (of course, it returns a delimited list [string], not a native
array, but the one-step method is there).  Is there anything in
PHP-land that does that?  Or am I pretty much stuck using some
variation of the code above?

Christopher Watson
Principal Architect
The International Variable Star Index (VSX)
http://vsx.aavso.org

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



Re: [PHP] what's all the about then?

2006-08-30 Thread Jochem Maas
tedd wrote:
> At 2:19 PM +0200 8/30/06, Paul Scott wrote:
>> On Wed, 2006-08-30 at 13:10 +0100, Ross wrote:
>>>  (ii) what is the technique called
>>
>> Read up on MVC (Model View Controller) and the front end controller
>> design pattern.
>>
>> Wikipedia is a good start.
>>
>> --Paul
> 
> Interesting that someone finally put a name to something we've been
> doing for decades. We used to just call it input, process, and display,
> which to me seems simpler. In addition, if one used IPD, it's acronym
> would at least be in the right order.

seems whenever I write something that resembles a FrontController I end up
with a process() and a display() method ... small world.

> 
> tedd

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



Re: [PHP] substr and UTF-8

2006-08-30 Thread Michael B Allen
On Wed, 30 Aug 2006 10:08:36 -0400
Michael B Allen <[EMAIL PROTECTED]> wrote:

> On Wed, 30 Aug 2006 18:34:20 +0700
> "Peter Lauri" <[EMAIL PROTECTED]> wrote:
> 
> > Hi group,
> > 
> > I want to limit the number of characters that are shown in a script. The
> > characters happen to be Thai, and the page is encoded in UTF-8. Everything
> > works, except when I want to cut the text (just take start of string).
> > 
> > I do:
> > 
> > echo substr($thaistring, 0, 30);
> > 
> > The beginning of the string works fine, but the last character does mostly
> > "break". How can I determine the start and end of a character.
> 
> The last byte of a UTF-8 character does not have bit 8 set whereas all
> preceeding bytes do.

Actually this is false. I don't know what I was thinking. The high bit
will be set in all bytes of a UTF-8 byte sequence. If it's not it's an
ASCII character.

The bytes are actually layed out as follows [1]:

U- ___ U-007F:  0xxx
U-0080 ___ U-07FF:  110x 10xx
U-0800 ___ U-:  1110 10xx 10xx
U-0001 ___ U-001F:  0xxx 10xx 10xx 10xx

So there's no way to tell the last byte of a UTF-8 byte sequence but you
can tell if it's the first byt looking at bits 7 and 8. Specifically,
if bit 8 is not on, the character is ASCII and thus the "start" of a
new character. Otherwise, if bit 7 is on it's the start of a new UTF-8
byte sequence.

  function is_utf8_start($b) {
  return (($b & 0x80) == 0) || ($b & 0x40);
  }

Mike

[1] http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8

-- 
Michael B Allen
PHP Active Directory SSO
http://www.ioplex.com/

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



Re: [PHP] what's all the about then?

2006-08-30 Thread tedd

At 2:19 PM +0200 8/30/06, Paul Scott wrote:

On Wed, 2006-08-30 at 13:10 +0100, Ross wrote:

 (ii) what is the technique called


Read up on MVC (Model View Controller) and the front end controller
design pattern.

Wikipedia is a good start.

--Paul


Interesting that someone finally put a name to something we've been 
doing for decades. We used to just call it input, process, and 
display, which to me seems simpler. In addition, if one used IPD, 
it's acronym would at least be in the right order.


tedd
--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



[PHP] Check for unsafe HTML

2006-08-30 Thread Bogdan Ribic

Hi all,

  I need to check html that is entered by user for unsafe content (ie 
javascript, vbscript, onmouseover etc) and still keep "safe" tags. Is 
there any easy way for that?


Boban.

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



Re: [PHP] substr and UTF-8

2006-08-30 Thread Michael B Allen
On Wed, 30 Aug 2006 18:34:20 +0700
"Peter Lauri" <[EMAIL PROTECTED]> wrote:

> Hi group,
> 
> I want to limit the number of characters that are shown in a script. The
> characters happen to be Thai, and the page is encoded in UTF-8. Everything
> works, except when I want to cut the text (just take start of string).
> 
> I do:
> 
> echo substr($thaistring, 0, 30);
> 
> The beginning of the string works fine, but the last character does mostly
> "break". How can I determine the start and end of a character.

The last byte of a UTF-8 character does not have bit 8 set whereas all
preceeding bytes do.

Mike

-- 
Michael B Allen
PHP Active Directory SSO
http://www.ioplex.com/

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



RE: [PHP] what's all the about then?

2006-08-30 Thread Peter Lauri
Do this.

1. Create a script called hello.php with the following content:



2. Enter http://yoururl/hello.php?string=Hello

3. The page will say "Hello"

The content after the ? will be treated as GET variables in the http request
to the server. You can use this to change behavior of a script depending on
what the GET variables values are.

/Peter


-Original Message-
From: Ross [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, August 30, 2006 7:10 PM
To: php-general@lists.php.net
Subject: [PHP] what's all the about then?

There is a site which has interesting behaviour.

http://myurl.co.uk/index.php?p=latest

when I click the links the variable and the end changes changing the page.

http://myurl.co.uk/index.php?p=news

Can someone tell me

(i) how is this achived
(ii) what is the technique called
(iii) does it have any real benefits apprt from looking a bit nifty


Ross 

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

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



RE: [PHP] what's all the about then?

2006-08-30 Thread Jay Blanchard
[snip]
There is a site which has interesting behaviour.

http://myurl.co.uk/index.php?p=latest

when I click the links the variable and the end changes changing the
page.

http://myurl.co.uk/index.php?p=news

Can someone tell me

(i) how is this achived
(ii) what is the technique called
(iii) does it have any real benefits apprt from looking a bit nifty
[/snip]

Unfortunately there are no links to click, there is a temporarily parked
message. What you are describing is using the GET method of posting
data.

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



Re: [PHP] send a file or stream

2006-08-30 Thread Rafael Mora

Hi!!

Well it works now, but with another issue, when I download it, it says that
it size is 0 bytes!!

i fwrite the file in a while, is it correct?

header()...
while()
{
 fwrite($da, "$somevar1:$somevar2");
}
fclose($da);

readfile();

thanks



On 8/30/06, Peter Lauri <[EMAIL PROTECTED]> wrote:


Try this:

header("Pragma: public");
header("Expires: 0"); // set expiration time
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-Type: application/octet-stream");
header('Content-Disposition: attachment; filename="stations.gzip"');
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".filesize(stations.gzip));
readfile("stations.gzip");

/Peter

PS! To maintain the list and its functionality, do not post same message
multiple times  DS!


-Original Message-
From: Rafael Mora [mailto:[EMAIL PROTECTED]
Sent: Wednesday, August 30, 2006 11:01 AM
To: Peter Lauri
Cc: php-general@lists.php.net
Subject: Re: [PHP] send a file or stream

Ok it works, but it returns me the same .php file, not the one I am
creating



On 8/29/06, Peter Lauri <[EMAIL PROTECTED]> wrote:
>
> You need to make sure that you are not outputting ANYTHING before you do
> this. I might guess that you have a whitespace in the top of the script.
As
> soon as you output, the server can not send any more header information,
and
> the browser will think it is just text instead of treating it as an
> octet-stream.
>
>
>
> /Peter
>
>
>
> _
>
> From: Rafael Mora [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, August 30, 2006 10:25 AM
> To: Peter Lauri
> Cc: php-general@lists.php.net
> Subject: Re: [PHP] send a file or stream
>
>
>
> I test it and gave me this: xœ ÉÈ,V¢D…'Ôâ=(r)(??/§C0/¿D!1O!3·
> ¿¨$1¯D¡¸¤(3/] LÖ‑ so the user should read that?? this is my code:
>
>
>
>  $params = array('level' => 6, 'window' => 15, 'memory' => 9);
>
> $texto_original = "This is a test.\nThis is only a test.\nThis is not an
> important string.\n";
> //echo "El texto original tiene " . strlen($texto_original) . "
> caracteres.\n";
>
> $da = fopen('stations.gzip', 'w');
> stream_filter_append($da, 'zlib.deflate', STREAM_FILTER_WRITE, $params);
> fwrite($da, $texto_original);
> fclose($da);
>
> header("Content-Type: application/octet-stream");
> readfile("stations.gzip");
>
>
>
>
>
> On 8/29/06, Peter Lauri <[EMAIL PROTECTED]> wrote:
>
>  header("Content-Type: application/octet-stream");
> readfile("path_to_compressed_file");
> ?>
>
>
>
> Should do it then. if you know the path to the file :)
>
>
>
> _
>
> From: Rafael Mora [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, August 30, 2006 10:10 AM
> To: Peter Lauri
> Subject: Re: [PHP] send a file or stream
>
>
>
> 1. A user sends a request to your server to get a compressed file
> 2. You compress the file on the server
> 3. I want to send back the file to the user
>
>
>
>
>
>
>
> On 8/29/06, Peter Lauri <[EMAIL PROTECTED]> wrote:
>
> Do you mean the following:
>
> 1. A user sends a request to your server to get a compressed file
> 2. You compress the file on the server
> 3. You want to send back to compressed file to the server
>
> It is number 3 you asking for?
>
> In that case:
>
>  header("Content-Type: application/octet-stream");
> readfile("path_to_compressed_file");
> ?>
>
> /Peter
>
>
> -Original Message-
> From: Rafael Mora [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, August 30, 2006 2:34 AM
> To: php-general@lists.php.net
> Subject: [PHP] send a file or stream
>
> Hi!
>
> i want to send a file or output stream in a .php, but first compress it,
I
> tryed the example to compress files but how do i do to send as answer to
> the
>
> http request??
>
> Rafa
>
>
>
>
>
>
>
>
>

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




Re: [PHP] Re: character set when sending emails with PHP

2006-08-30 Thread Jon Anderson

Angelo Zanetti wrote:
thanks for the reply, I've got the classes now how do I know which 
character set to use for the TM to be shown correctly?


Character sets can be a nasty business...

You were using the ISO-8859-1 character set in your headers. TM doesn't 
exist in that character set. That's why it showed up as a box in many 
email clients.


You should probably find out what character set you're 
using/storing/sending - if you're using Windows, it's probably Windows 
CP1252 (http://en.wikipedia.org/wiki/CP1252). UTF-8 (any many others) 
also support(s) the TM symbol, but chances are that your OS doesn't use 
UTF-8 by default.


You can use PHP's multi-byte string functions to manipulate character 
sets, but be warned that there are "tricks" to it, for example, 
mb_detect_encoding will detect CP1252 as ISO-8859-x, so you have to 
manually specify CP1252 for conversion if you're sure that's the source 
character set. (There are other character sets that seem to have similar 
behavior too.)


Of course email needs to be sent in 7-bit ASCII, so you'd need to encode 
your message with quoted-printable or equivalent. The classes mentioned 
earlier probably accomplish this.


jon

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



Re: [PHP] what's all the about then?

2006-08-30 Thread Paul Scott

On Wed, 2006-08-30 at 13:10 +0100, Ross wrote:
> (ii) what is the technique called

Read up on MVC (Model View Controller) and the front end controller
design pattern.

Wikipedia is a good start.

--Paul

All Email originating from UWC is covered by disclaimer 
http://www.uwc.ac.za/portal/uwc2006/content/mail_disclaimer/index.htm 

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

Re: [PHP] what's all the about then?

2006-08-30 Thread Jochem Maas
Ross wrote:
> There is a site which has interesting behaviour.
> 
> http://myurl.co.uk/index.php?p=latest
> 
> when I click the links the variable and the end changes changing the page.
> 
> http://myurl.co.uk/index.php?p=news
> 
> Can someone tell me
> 
> (i) how is this achived

index.php --->
 (ii) what is the technique called

search for terms like 'front controller', 'request dispatcher'

> (iii) does it have any real benefits apprt from looking a bit nifty

sometimes a modular cms (for example) can be extended and automatically
generate useful URLs by using a URL scheme such as this.

> 
> 
> Ross 
> 

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



Re: [PHP] substr and UTF-8

2006-08-30 Thread Jochem Maas
Peter Lauri wrote:
> Hi group,
> 
> I want to limit the number of characters that are shown in a script. The
> characters happen to be Thai, and the page is encoded in UTF-8. Everything
> works, except when I want to cut the text (just take start of string).
> 
> I do:
> 
> echo substr($thaistring, 0, 30);
> 
> The beginning of the string works fine, but the last character does mostly
> "break". How can I determine the start and end of a character.

become familiar with (and install) the mb_string extension

> 
> I hope the problem is clear enough, is it? :)
> 
> Best regards,
> Peter Lauri
> 
> www.lauri.se - personal web site
> www.dwsasia.com - company web site
> 

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



[PHP] what's all the about then?

2006-08-30 Thread Ross
There is a site which has interesting behaviour.

http://myurl.co.uk/index.php?p=latest

when I click the links the variable and the end changes changing the page.

http://myurl.co.uk/index.php?p=news

Can someone tell me

(i) how is this achived
(ii) what is the technique called
(iii) does it have any real benefits apprt from looking a bit nifty


Ross 

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



[PHP] substr and UTF-8

2006-08-30 Thread Peter Lauri
Hi group,

I want to limit the number of characters that are shown in a script. The
characters happen to be Thai, and the page is encoded in UTF-8. Everything
works, except when I want to cut the text (just take start of string).

I do:

echo substr($thaistring, 0, 30);

The beginning of the string works fine, but the last character does mostly
"break". How can I determine the start and end of a character.

I hope the problem is clear enough, is it? :)

Best regards,
Peter Lauri

www.lauri.se - personal web site
www.dwsasia.com - company web site

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



RE: [PHP] Not using cached version

2006-08-30 Thread Peter Lauri
Thanks. I went for the version where I use the path to the file instead :)

/Peter

-Original Message-
From: Stut [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, August 30, 2006 5:02 PM
To: Peter Lauri
Cc: php-general@lists.php.net
Subject: Re: [PHP] Not using cached version

Peter Lauri wrote:
> I have some images stored in a database (only file name and other relevant
> information, rest stored in file system).
>
> I use the following html to access them: 
>
> 
>
> At some pages I have the same image, so that tag will be seen on multiple
> places on the same page. So what I am curious is why all of the different
> images are loaded separately, instead of just recognizing that they are
the
> same and use a cache version?
>
> This is the code that do all the work:
>
>   Header ("Content-type: $image_type");
>   readfile("files/$image");
>
> I am a little bit lost here; kick me in the right direction if you can :)
>   

Probably because the browser sees the ? in the URL, thinks dynamic and 
doesn't cache the result. You can set caching headers to get around this 
(Google for it), or if you want *all* browsers to do it right, even the 
poorly implemented ones, you could modify the URL so it doesn't have the 
?. I do this using the Apache MultiViews option and a URL similar to 
/image/123.gif. That actually runs /image.php which pulls the 
REQUEST_URI server variable apart to get the required image. Do both and 
you should be good for all browsers.

-Stut

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

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



Re: [PHP] Not using cached version

2006-08-30 Thread Stut

Peter Lauri wrote:

I have some images stored in a database (only file name and other relevant
information, rest stored in file system).

I use the following html to access them: 




At some pages I have the same image, so that tag will be seen on multiple
places on the same page. So what I am curious is why all of the different
images are loaded separately, instead of just recognizing that they are the
same and use a cache version?

This is the code that do all the work:

  Header ("Content-type: $image_type");
  readfile("files/$image");

I am a little bit lost here; kick me in the right direction if you can :)
  


Probably because the browser sees the ? in the URL, thinks dynamic and 
doesn't cache the result. You can set caching headers to get around this 
(Google for it), or if you want *all* browsers to do it right, even the 
poorly implemented ones, you could modify the URL so it doesn't have the 
?. I do this using the Apache MultiViews option and a URL similar to 
/image/123.gif. That actually runs /image.php which pulls the 
REQUEST_URI server variable apart to get the required image. Do both and 
you should be good for all browsers.


-Stut

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



Re: [PHP] replace single and double quotes

2006-08-30 Thread Jochem Maas
Rafael Mora wrote:
> Hi!
> 
> i want to send a file or output stream in a .php, but first compress it, I
> tryed the example to compress files but how do i do to send as answer to
> the
> http request??

trye the other example


> 
> Rafa
> 

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



[PHP] Not using cached version

2006-08-30 Thread Peter Lauri
Hi,

I have some images stored in a database (only file name and other relevant
information, rest stored in file system).

I use the following html to access them: 



At some pages I have the same image, so that tag will be seen on multiple
places on the same page. So what I am curious is why all of the different
images are loaded separately, instead of just recognizing that they are the
same and use a cache version?

This is the code that do all the work:

  Header ("Content-type: $image_type");
  readfile("files/$image");

I am a little bit lost here; kick me in the right direction if you can :)

/Peter

www.lauri.se - my personal blog
www.dwsasia.com - the company I work for

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



Re: [PHP] Re: character set when sending emails with PHP

2006-08-30 Thread Angelo Zanetti



Manuel Lemos wrote:


Hello,

on 08/29/2006 09:04 AM Angelo Zanetti said the following:
 


I have various PHP CRONTAB scripts that run and send automated emails to
people, the subject often contains the "TM" character: ™, in most of the
email clients the character shows correctly but in some webmail
applications the character is replaced with a square, it obviously
doesnt recognise the character. Now if I forward one the mails from the
email client to the webmail account it then recognises and shows the
character correctly? Very weird as it is the same mail just forwarded,
is the problem that the mail forwarded from the email client uses a
different content type when sent? The one specified in the PHP script is
as follows:

$mail->setHeader("Content-type", "text/plain; charset=iso-8859-1");

Or is there something wrong with the charset that I'm specifying above?
   



The content-type header only applies to that message body part. The
character set of the headers is defined in a different way using q-encoding.

Take a look at this class that lets you define headers with whatever
encoding and character set you need to use:

http://www.phpclasses.org/mimemessage


 


hi Manuel.

thanks for the reply, I've got the classes now how do I know which 
character set to use for the TM to be shown correctly?


Thanks in advance.
--

Angelo Zanetti
Systems developer


*Telephone:* +27 (021) 469 1052
*Mobile:*   +27 (0) 72 441 3355
*Fax:*+27 (0) 86 681 5885
*
Web:* http://www.zlogic.co.za
*E-Mail:* [EMAIL PROTECTED] 

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



Re: [PHP] Strange situation when saving a file

2006-08-30 Thread Stut

Miguel Guirao wrote:

I'm using ob_start() in order to save the content of a web page into a
variable string and then save it into a file in the file system. Every thing
is done OK. The only workaround I'm doing is adding a .doc file extension
when saving the file, in order to open the file in Word.

Once the file has been created and saved as I doc file (not a doc format!),
I e-mail it!

When the client gets the e-mail, he/she should open the file either by
saving the file to the local system or openning the file directly from the
e-mail attachment. Either way, I got a blank page in Word. If I open the
document directly from the web server, without having it sent by e-mail, it
opens correctly in Word. The only problem is when the file is been
emailed!!!


What could be going wrong?? Any ideas??
  


My crystal ball tells me that there's something wrong with your code. 
Unfortunately, due to the lead shield that surrounds all PHP code I 
cannot see it from here. I suggest your next step would be to remove 
said shield by emailing the relevant parts to the list. Then we may be 
able to bring our collective skills together to assist in solving your 
problem.


-Stut

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



[PHP] BMP and GDlib

2006-08-30 Thread Peter Lauri
Hi group,

 

I have noticed that GD-lib does not support BMP images. In the user comment
on the manual page there is a note that one can use bmp2png function to
convert that (http://cetus.sakura.ne.jp/softlab/b2p-home/) This is not
applicable for me when I do not want to run any outside scripts.

 

So the question is:

 

Is there really no function in php so that I can recreate a BMP and change
the size of it? I have it all working with jpg and gif.

 

/Peter