Re: [PHP] Image Verification - Problems in Safari, Mac OS X

2005-05-24 Thread Richard Lynch
On Mon, May 23, 2005 8:46 am, Rahul S. Johari said:
 If I had misunderstood your method and you think your method is better
 then
 what I'm using now, I'd still really appreciate if you can clarify and
 explain.

Your method is fine.

In fact, it penalizes IE for some stupidity in its caching, which is Good
because maybe they'll fix it if their cache becomes increasingly useless
as everybody does this to avoid their stupid bugs.

In theory, the ?$random_string should have forced the browser to load a
new/different image each time... It's hard to imagine even Microsoft could
screw that up, but you never know with Microsoft on this issue...

One possible improvement, however, is this:

The random part of the URL that you need to use to make Microsoft *NOT*
cache an image doesn't have to be tied to the actual algorithm that
creates the image.

Consider this example:

 index.html ---
?php
  $fool_microsoft = mt_rand(1, 200);
?
img src=random.php/?php echo $fool_microsoft?/example.png
---


 random.php ---
?php
  $heads = mt_rand(0, 1) ? 'heads' : 'tails';
  $image = imagecreatetruecolor(100, 100);
  $white = imagecolorallocate($image, 255, 255, 255);
  $black = imagecolorallocate($image, 0, 0, 0);
  imagefilledrectangle($image, 0, 0, 100, 100, $white);
  imagestring($image, $heads, 10, 60, $black);
  header(Content-type: image/png);
  imagepng($image);
?

The HUGE random number in the URL that forces MS to never cache my
coin-flipping image has nothing to do with the heads/tails outcome.

I don't know if this will help you have less clutter in your images or
not, but it might be useful some day.

-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] Image Verification - Problems in Safari, Mac OS X

2005-05-23 Thread Rahul S. Johari
Ave,


On 5/21/05 9:11 AM, Ryan A [EMAIL PROTECTED] wrote:

 eg:
 
 first have a function to generate a modest random string (I use 8 chars)
 
 then in the image calling part call it something like this:
 
 img src='?php echo $your_image_gets_called_here; ???php echo
 $the_rand_string; ?'
 
 as you can see above, its an over simplified version, but you can tune it as
 you go along...works
 everytime for me.

Calling my image and then assigning a random string as a query string didn't
really help.. I don't know if I did it correctly or misunderstood the logic
you were implying. What I did made my image look like verify.png?839838ksh8
... But that didn't really make IE display the fresh image.. It still
displayed the old image from cache, only the Query string was a unique
random string each time.

However, your theory gave me another idea which works for now! Instead of
defining the image name as verify.png.. I have defined the image name to be
the random string. Each time the page opens.. A new image is created with a
new image name... Thus IE cannot display the old image from it's cache
because the image name's differ.

The con of this method is that every time someone accesses this page, a new
image will be created and stored in the folder, taking up byte space. I'll
definitely run up a script to erase images a day old though.

For now this works.. I don't know if it's the best way to do this, but
considering nothing regarding the Cache was working, I don't mind doing this
for now, at least the application is working.

If I had misunderstood your method and you think your method is better then
what I'm using now, I'd still really appreciate if you can clarify and
explain.

Thanks again,

Rahul S. Johari
Coordinator, Internet  Administration
Informed Marketing Services Inc.
251 River Street
Troy, NY 12180

Tel: (518) 266-0909 x154
Fax: (518) 266-0909
Email: [EMAIL PROTECTED]
http://www.informed-sources.com

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



Re: [PHP] Image Verification - Problems in Safari, Mac OS X

2005-05-21 Thread Ryan A
Hey,

used to have the same problem, solved it by having a random string in the
img calling part.

eg:

first have a function to generate a modest random string (I use 8 chars)

then in the image calling part call it something like this:

img src='?php echo $your_image_gets_called_here; ???php echo
$the_rand_string; ?'

as you can see above, its an over simplified version, but you can tune it as
you go along...works
everytime for me.


Cheers,
Ryan

On 5/21/2005 4:04:00 AM, Richard Lynch ([EMAIL PROTECTED]) wrote:
 On Thu, May 19, 2005 6:05 am, Rahul S. Johari said:
  I did actually remove the Header which declared it as a Image/PNG and
  everything seemed to work in both the browsers.

 Great.  Now it works in 2 browsers, and breaks in 237.

 You MUST separate the two.

 Period.

  Here's my situation though... I can't separate out these two files
 because
  when a user is on the verification page, where the Image exists, in
 case
  he
  reloads or refreshes the page, a new image should be generated and
  displayed, so that the verification code is different each time you
 reach
  the verification page. If I was to keep the image code in a
 different
  page,
  the verification page will pick up the same PNG image and display the
 same
  security code over and over without changing it.

 So you need some kind of secret token buried in the HTML which you can
 decode in the image and in their submit to see if they actually used
 human
 eyeballs to see the image.

 There are dozens of scripts out there that do this -- Perhaps you should
 review them to see how they work.



-- 
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.322 / Virus Database: 266.11.14 - Release Date: 5/20/2005

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



Re: [PHP] Image Verification - Problems in Safari, Mac OS X

2005-05-21 Thread Marek Kilimajer

Richard Lynch wrote:

On Thu, May 19, 2005 6:05 am, Rahul S. Johari said:


I did actually remove the Header which declared it as a Image/PNG and
everything seemed to work in both the browsers.



Great.  Now it works in 2 browsers, and breaks in 237.

You MUST separate the two.


Actualy he always did:

ImagePNG($im, verify.png);

This saved the image, not output.

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



Re: [PHP] Image Verification - Problems in Safari, Mac OS X

2005-05-20 Thread Rahul S. Johari

Ave,

On 5/19/05 6:08 PM, Rory Browne [EMAIL PROTECTED] wrote:

 if you have an image generated by
 http://www.example.com/createimage.php , you could always refer to it
 as http://www.example.com/createimage.php/{no_of_seconds_since_unix_epoch}.png

It's sounding logical, but could you explain a little more... I'm not sure
how to use no_of_seconds_since_unix_epoch ...

Thanks,

Rahul S. Johari
Coordinator, Internet  Administration
Informed Marketing Services Inc.
251 River Street
Troy, NY 12180

Tel: (518) 266-0909 x154
Fax: (518) 266-0909
Email: [EMAIL PROTECTED]
http://www.informed-sources.com

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



Re: [PHP] Image Verification - Problems in Safari, Mac OS X

2005-05-20 Thread Rahul S. Johari

Ave,

On 5/19/05 5:41 PM, Marek Kilimajer [EMAIL PROTECTED] wrote:

 If more then one user is accesing the page, you might overwrite the
 first one's verify.png image. Simple and sufficient solution is to
 append a random string to the filename:
 
 $image_filename= 'verify_' . md5(rand()) . '.png';
 ImagePNG($im, $image_filename);
 ?
 img src=?php echo $image_filename; ? width=200 height=40
 ?php
 
 Just remember to add some way to remove old images.

Solutions works for me too... Gets rid of the multi-user problem. Thanks for
pointing it out and suggesting the solution.

The other Cache problem still persists. Don't know what to do about it. Is
just not working out in IE.
 

Rahul S. Johari
Coordinator, Internet  Administration
Informed Marketing Services Inc.
251 River Street
Troy, NY 12180

Tel: (518) 266-0909 x154
Fax: (518) 266-0909
Email: [EMAIL PROTECTED]
http://www.informed-sources.com

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



Re: [PHP] Image Verification - Problems in Safari, Mac OS X

2005-05-20 Thread Richard Lynch
On Thu, May 19, 2005 6:05 am, Rahul S. Johari said:
 I did actually remove the Header which declared it as a Image/PNG and
 everything seemed to work in both the browsers.

Great.  Now it works in 2 browsers, and breaks in 237.

You MUST separate the two.

Period.

 Here's my situation though... I can't separate out these two files because
 when a user is on the verification page, where the Image exists, in case
 he
 reloads or refreshes the page, a new image should be generated and
 displayed, so that the verification code is different each time you reach
 the verification page. If I was to keep the image code in a different
 page,
 the verification page will pick up the same PNG image and display the same
 security code over and over without changing it.

So you need some kind of secret token buried in the HTML which you can
decode in the image and in their submit to see if they actually used human
eyeballs to see the image.

There are dozens of scripts out there that do this -- Perhaps you should
review them to see how they work.

The simplest solution I know of is to make up a random string and store it
in an SQL table with the word in the image.

http://php.net/uniquid http://php.net/md5 etc.

-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] Image Verification - Problems in Safari, Mac OS X

2005-05-19 Thread Rahul S. Johari

On 5/18/05 7:19 PM, Richard Lynch [EMAIL PROTECTED] wrote:

 Your image is *NOT* a DOCTYPE HTML PUBLIC blah blah!!!
 
 It's a *IMAGE*
 
 Get rid of all the HMTL stuff.
 
 You actually need to separate this into two different files.
 
 One has all the HTML in it, with a SRC=/URL/to/image.php/image.png
 
 The other is JUST the image stuff.
 
 If IE actually displays it as-is, that's pretty broken...  But IE is
 pretty broken as it is, so one more broken-ness shouldn't surprise
 anybody.


Ave,

Here's the problem.
I completely understand what's going on and that actually it was IE screwing
it up and Safari was actually doing the right thing. But my problem only
deepens right now with IE.

I did actually remove the Header which declared it as a Image/PNG and
everything seemed to work in both the browsers.

Here's my situation though... I can't separate out these two files because
when a user is on the verification page, where the Image exists, in case he
reloads or refreshes the page, a new image should be generated and
displayed, so that the verification code is different each time you reach
the verification page. If I was to keep the image code in a different page,
the verification page will pick up the same PNG image and display the same
security code over and over without changing it.

Removing the header with image/PNG actually was working for both browsers, I
could keep both the codes on one page and the page could be
refreshed/reloaded to display new security code... Or reached from anywhere
and you'd still have a new security code.

But here's the problem that came afterwards in IE !
IE is storing the image in it's cache.. And it's displaying the same image
on the verification page whether you use the BACK button, FORWARD button, or
actually go through the website and land back on the verification page. So
in IE, right now, unless you actually HIT the REFRESH button, it's not
changing the image as it's picking up the image from the Cache.

Now I'm not sure what exactly I should do to fix this whole situation.

Thanks all,

Rahul S. Johari
Coordinator, Internet  Administration
Informed Marketing Services Inc.
251 River Street
Troy, NY 12180

Tel: (518) 266-0909 x154
Fax: (518) 266-0909
Email: [EMAIL PROTECTED]
http://www.informed-sources.com

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



Re: [PHP] Image Verification - Problems in Safari, Mac OS X

2005-05-19 Thread Rahul S. Johari

On 5/18/05 6:23 PM, Marek Kilimajer [EMAIL PROTECTED] wrote:

 BTW, you might not be concerned about it much, but you have a race
 condition in your script.

Ave,

What do you mean by race condition ?


Rahul S. Johari
Coordinator, Internet  Administration
Informed Marketing Services Inc.
251 River Street
Troy, NY 12180

Tel: (518) 266-0909 x154
Fax: (518) 266-0909
Email: [EMAIL PROTECTED]
http://www.informed-sources.com

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



RE: [PHP] Image Verification - Problems in Safari, Mac OS X

2005-05-19 Thread Murray @ PlanetThoughtful
 But here's the problem that came afterwards in IE !
 IE is storing the image in it's cache.. And it's displaying the same image
 on the verification page whether you use the BACK button, FORWARD button,
 or
 actually go through the website and land back on the verification page. So
 in IE, right now, unless you actually HIT the REFRESH button, it's not
 changing the image as it's picking up the image from the Cache.
 
 Now I'm not sure what exactly I should do to fix this whole situation.

Try forcing the browser to bypass the cache by adding the lines at the
following link to your page:

http://www.faqts.com/knowledge_base/view.phtml/aid/21068/fid/51

Regards,

Murray

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



Re: [PHP] Image Verification - Problems in Safari, Mac OS X

2005-05-19 Thread Rahul S. Johari

On 5/19/05 10:59 AM, Murray @ PlanetThoughtful
[EMAIL PROTECTED] wrote:


 Try forcing the browser to bypass the cache by adding the lines at the
 following link to your page:
 
 http://www.faqts.com/knowledge_base/view.phtml/aid/21068/fid/51

I thought this would definitely work because it looks like exactly what I
need. IE is picking up the image from the cache no matter what.. And it
seemed this piece of code is exactly for that, so that IE doesn't pick up
images/data from the cache. But it's still not working! IE is still indeed
picking up the image from the cache.

This is how the beginning of my php page looks like:

?php
session_start(); 
header (Expires: Mon, 26 Jul 1997 05:00:00 GMT); // Date in the past
header (Last-Modified:  . gmdate(D, d M Y H:i:s) .  GMT);
header (Cache-Control: no-cache, must-revalidate); // for HTTP/1.1
header (Pragma: no-cache); // for HTTP/1.0
?

Stll... IE is displaying the image that has already been displayed on first
login attempt... It won't display new Image untill you actually physically
hit the REFRESH button on the browser.

Any suggestions? 

Rahul S. Johari
Coordinator, Internet  Administration
Informed Marketing Services Inc.
251 River Street
Troy, NY 12180

Tel: (518) 266-0909 x154
Fax: (518) 266-0909
Email: [EMAIL PROTECTED]
http://www.informed-sources.com

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



Re: [PHP] Image Verification - Problems in Safari, Mac OS X

2005-05-19 Thread Marek Kilimajer
Rahul S. Johari wrote:
On 5/18/05 6:23 PM, Marek Kilimajer [EMAIL PROTECTED] wrote:

BTW, you might not be concerned about it much, but you have a race
condition in your script.

Ave,
What do you mean by race condition ?
If more then one user is accesing the page, you might overwrite the 
first one's verify.png image. Simple and sufficient solution is to 
append a random string to the filename:

$image_filename= 'verify_' . md5(rand()) . '.png';
ImagePNG($im, $image_filename);
?
img src=?php echo $image_filename; ? width=200 height=40
?php
Just remember to add some way to remove old images.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Image Verification - Problems in Safari, Mac OS X

2005-05-19 Thread Rory Browne
if you have an image generated by
http://www.example.com/createimage.php , you could always refer to it
as http://www.example.com/createimage.php/{no_of_seconds_since_unix_epoch}.png

On 5/19/05, Rahul S. Johari [EMAIL PROTECTED] wrote:
 
 On 5/19/05 10:59 AM, Murray @ PlanetThoughtful
 [EMAIL PROTECTED] wrote:
 
 
  Try forcing the browser to bypass the cache by adding the lines at the
  following link to your page:
 
  http://www.faqts.com/knowledge_base/view.phtml/aid/21068/fid/51
 
 I thought this would definitely work because it looks like exactly what I
 need. IE is picking up the image from the cache no matter what.. And it
 seemed this piece of code is exactly for that, so that IE doesn't pick up
 images/data from the cache. But it's still not working! IE is still indeed
 picking up the image from the cache.
 
 This is how the beginning of my php page looks like:
 
 ?php
 session_start();
 header (Expires: Mon, 26 Jul 1997 05:00:00 GMT); // Date in the past
 header (Last-Modified:  . gmdate(D, d M Y H:i:s) .  GMT);
 header (Cache-Control: no-cache, must-revalidate); // for HTTP/1.1
 header (Pragma: no-cache); // for HTTP/1.0
 ?
 
 Stll... IE is displaying the image that has already been displayed on first
 login attempt... It won't display new Image untill you actually physically
 hit the REFRESH button on the browser.
 
 Any suggestions?
 
 Rahul S. Johari
 Coordinator, Internet  Administration
 Informed Marketing Services Inc.
 251 River Street
 Troy, NY 12180
 
 Tel: (518) 266-0909 x154
 Fax: (518) 266-0909
 Email: [EMAIL PROTECTED]
 http://www.informed-sources.com
 
 --
 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



[PHP] Image Verification - Problems in Safari, Mac OS X

2005-05-18 Thread Rahul S. Johari
Ave,

A simple Image Verification script is working perfect in IE on Windows...
But isn¹t working in Safari on Mac OS X! It displays a blank page instead of
the image with the form. Here¹ s the Script:

?
header(Content-Type: image/png);
session_start(); 
$new_string; 
session_register('new_string');
?
!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN
http://www.w3.org/TR/html4/loose.dtd;
HTML
HEAD
META http-equiv=Content-Type content=text/html; charset=iso-8859-1
TITLEVerification : IMSAFM/TITLE
/HEAD
BODY
?php
$im = ImageCreate(200, 40);

$white = ImageColorAllocate($im, 255, 255, 255);
$black = ImageColorAllocate($im, 0, 0, 0);

srand((double)microtime()*100);
$string = md5(rand(0,));
$new_string = substr($string, 17, 5);
ImageFill($im, 0, 0, $black);
ImageString($im, 4, 96, 19, $new_string, $white);
ImagePNG($im, verify.png);
ImageDestroy($im); 
?

img src=verify.png width=200 height=40brbr
Type the code you see in the image in the box below. (case sensitive)
form action=verified.php method=post
input name=random type=text value=
input type=submit
/form
/BODY
/HTML

Any tips to make it work in Safari as well?

Thanks,

Rahul S. Johari
Coordinator, Internet  Administration
Informed Marketing Services Inc.
251 River Street
Troy, NY 12180

Tel: (518) 266-0909 x154
Fax: (518) 266-0909
Email: [EMAIL PROTECTED]
http://www.informed-sources.com



Re: [PHP] Image Verification - Problems in Safari, Mac OS X

2005-05-18 Thread Jason Wong
On Thursday 19 May 2005 03:51, Rahul S. Johari wrote:

 A simple Image Verification script is working perfect in IE on
 Windows... But isnt working in Safari on Mac OS X! It displays a blank
 page instead of the image with the form. Here s the Script:

That's because IE is severely broken? In short, you're trying to display 
an image, so get rid of all the HTML stuff.

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
New Year Resolution: Ignore top posted posts

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



Re: [PHP] Image Verification - Problems in Safari, Mac OS X

2005-05-18 Thread Marek Kilimajer
Rahul S. Johari wrote:
Ave,
A simple Image Verification script is working perfect in IE on Windows...
But isn¹t working in Safari on Mac OS X! It displays a blank page instead of
the image with the form. Here¹ s the Script:
?
header(Content-Type: image/png);
Because only Safari gets it right. With the above line you are saing 
this html page is a PNG image. The png file is saved, not output. Remove 
the line.

BTW, you might not be concerned about it much, but you have a race 
condition in your script.

session_start(); 
$new_string; 
session_register('new_string');
?
!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN
http://www.w3.org/TR/html4/loose.dtd;
HTML
HEAD
META http-equiv=Content-Type content=text/html; charset=iso-8859-1
TITLEVerification : IMSAFM/TITLE
/HEAD
BODY
?php
$im = ImageCreate(200, 40);

$white = ImageColorAllocate($im, 255, 255, 255);
$black = ImageColorAllocate($im, 0, 0, 0);
srand((double)microtime()*100);
$string = md5(rand(0,));
$new_string = substr($string, 17, 5);
ImageFill($im, 0, 0, $black);
ImageString($im, 4, 96, 19, $new_string, $white);
ImagePNG($im, verify.png);
ImageDestroy($im); 
?

img src=verify.png width=200 height=40brbr
Type the code you see in the image in the box below. (case sensitive)
form action=verified.php method=post
input name=random type=text value=
input type=submit
/form
/BODY
/HTML
Any tips to make it work in Safari as well?
Thanks,
Rahul S. Johari
Coordinator, Internet  Administration
Informed Marketing Services Inc.
251 River Street
Troy, NY 12180
Tel: (518) 266-0909 x154
Fax: (518) 266-0909
Email: [EMAIL PROTECTED]
http://www.informed-sources.com

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


Re: [PHP] Image Verification - Problems in Safari, Mac OS X

2005-05-18 Thread Richard Lynch
Your image is *NOT* a DOCTYPE HTML PUBLIC blah blah!!!

It's a *IMAGE*

Get rid of all the HMTL stuff.

You actually need to separate this into two different files.

One has all the HTML in it, with a SRC=/URL/to/image.php/image.png

The other is JUST the image stuff.

If IE actually displays it as-is, that's pretty broken...  But IE is
pretty broken as it is, so one more broken-ness shouldn't surprise
anybody.


On Wed, May 18, 2005 12:51 pm, Rahul S. Johari said:
 Ave,

 A simple Image Verification script is working perfect in IE on Windows...
 But isn¹t working in Safari on Mac OS X! It displays a blank page instead
 of
 the image with the form. Here¹ s the Script:

 ?
 header(Content-Type: image/png);
 session_start();
 $new_string;
 session_register('new_string');
 ?
 !DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN
 http://www.w3.org/TR/html4/loose.dtd;
 HTML
 HEAD
 META http-equiv=Content-Type content=text/html; charset=iso-8859-1
 TITLEVerification : IMSAFM/TITLE
 /HEAD
 BODY
 ?php
 $im = ImageCreate(200, 40);

 $white = ImageColorAllocate($im, 255, 255, 255);
 $black = ImageColorAllocate($im, 0, 0, 0);

 srand((double)microtime()*100);
 $string = md5(rand(0,));
 $new_string = substr($string, 17, 5);
 ImageFill($im, 0, 0, $black);
 ImageString($im, 4, 96, 19, $new_string, $white);
 ImagePNG($im, verify.png);
 ImageDestroy($im);
 ?

 img src=verify.png width=200 height=40brbr
 Type the code you see in the image in the box below. (case sensitive)
 form action=verified.php method=post
 input name=random type=text value=
 input type=submit
 /form
 /BODY
 /HTML

 Any tips to make it work in Safari as well?

 Thanks,

 Rahul S. Johari
 Coordinator, Internet  Administration
 Informed Marketing Services Inc.
 251 River Street
 Troy, NY 12180

 Tel: (518) 266-0909 x154
 Fax: (518) 266-0909
 Email: [EMAIL PROTECTED]
 http://www.informed-sources.com




-- 
Like Music?
http://l-i-e.com/artists.htm

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