Author |
Topic: Grimbal's Personalized Picture (Read 6956 times) |
|
alien
Guest
|
Is Grimbal changing his personalized picture in his profile every time he connects to wu :: forums or is there another (automatic) way?
|
|
IP Logged |
|
|
|
Aryabhatta
Uberpuzzler
Gender:
Posts: 1321
|
|
Re: Grimbal's Personalized Picture
« Reply #1 on: Sep 27th, 2004, 8:34pm » |
Quote Modify
|
You can specify an external link for your personalized picture. Grimbal's is http://florian.net/pic/65x65/mypic.php?.gif Question is, how does his script manage to return the same pic for a long topic to which he has posted many times? Maybe he is using cookies. Anyway, hope that helps.
|
|
IP Logged |
|
|
|
ThudnBlunder
wu::riddles Moderator Uberpuzzler
The dewdrop slides into the shining Sea
Gender:
Posts: 4489
|
|
Re: Grimbal's Personalized Picture
« Reply #2 on: Sep 27th, 2004, 8:37pm » |
Quote Modify
|
Quote:Question is, how does his script manage to return the same pic for a long topic to which he has posted many times? Maybe he is using cookies. |
| on Jun 14th, 2004, 1:50pm, Grimbal wrote:I change my mind all the time. No, actually, I quickly got bored of any avatar I chose, so I wrote a script that brings back a random picture among those I collected. |
| A script-kiddie, huh?
|
« Last Edit: Sep 28th, 2004, 4:07am by ThudnBlunder » |
IP Logged |
THE MEEK SHALL INHERIT THE EARTH.....................................................................er, if that's all right with the rest of you.
|
|
|
towr
wu::riddles Moderator Uberpuzzler
Some people are average, some are just mean.
Gender:
Posts: 13730
|
|
Re: Grimbal's Personalized Picture
« Reply #3 on: Sep 28th, 2004, 4:08am » |
Quote Modify
|
on Sep 27th, 2004, 8:34pm, Aryabhatta wrote:Question is, how does his script manage to return the same pic for a long topic to which he has posted many times? Maybe he is using cookies. |
| Or maybe your browser caches the image and uses it over and over instead of dowmloading the (from the browsers pov same) image again and again.. IF you can tell your browser to never cache images (or anything) it would probably be different more often, also inside topics.
|
|
IP Logged |
Wikipedia, Google, Mathworld, Integer sequence DB
|
|
|
John_Gaughan
Uberpuzzler
Behold, the power of cheese!
Gender:
Posts: 767
|
|
Re: Grimbal's Personalized Picture
« Reply #4 on: Sep 28th, 2004, 5:56am » |
Quote Modify
|
I noticed this too. I did not check the image URL but I imagine it is a script that picks an image at random (or by time, a new one every hour?) and writes it manually to the output stream with HTTP headers. At least that was what I was going to do but then I was too lazy to follow through with it
|
|
IP Logged |
x = (0x2B | ~0x2B) x == the_question
|
|
|
John_Gaughan
Uberpuzzler
Behold, the power of cheese!
Gender:
Posts: 767
|
|
Re: Grimbal's Personalized Picture
« Reply #5 on: Sep 28th, 2004, 6:04am » |
Quote Modify
|
on Sep 27th, 2004, 8:34pm, Aryabhatta wrote:Question is, how does his script manage to return the same pic for a long topic to which he has posted many times? |
| Possibly by checking the $SERVER['HTTP_REFERER'] PHP variable. When a web page has embedded objects such as images, flash animations, Java applets, et al, the browser requests those objects from the server using the web page's URL as the referrer. This forum has the thread ID and other information embedded in the URL, so parsing it out and serving a custom image is trivial. It is quite possible to write a script that checks the "Referer" header and serves different images based on it. I have run into web sites that do this at the web server (not CGI) level to save on bandwidth: if the server does not like the referrer, it denies the image. Images can eat up bandwidth, and image leachers tend to do more harm than good.
|
|
IP Logged |
x = (0x2B | ~0x2B) x == the_question
|
|
|
Aryabhatta
Uberpuzzler
Gender:
Posts: 1321
|
|
Re: Grimbal's Personalized Picture
« Reply #6 on: Sep 28th, 2004, 9:31am » |
Quote Modify
|
Quote: Or maybe your browser caches the image and uses it over and over instead of dowmloading the (from the browsers pov same) image again and again.. IF you can tell your browser to never cache images (or anything) it would probably be different more often, also inside topics. |
| I don't think most broswers would cache links which refer to scripts, though I am not sure. on Sep 28th, 2004, 6:04am, John_Gaughan wrote: Possibly by checking the $SERVER['HTTP_REFERER'] PHP variable. When a web page has embedded objects such as images, flash animations, Java applets, et al, the browser requests those objects from the server using the web page's URL as the referrer. This forum has the thread ID and other information embedded in the URL, so parsing it out and serving a custom image is trivial. It is quite possible to write a script that checks the "Referer" header and serves different images based on it. I have run into web sites that do this at the web server (not CGI) level to save on bandwidth: if the server does not like the referrer, it denies the image. Images can eat up bandwidth, and image leachers tend to do more harm than good. |
| Yes, that is a possibilty. There might be one problem with this though. If I immediately refresh the page for the discussion of a thread, the images change. How does the script figure out the difference? It might be a good puzzle to try and figure out what actually the script is doing. We can all try to provide evidence/proof as to what is going on, other can try to refute/support it and Grimbal (if he will be so kind) can then say what the script is actually doing (or provide hints).
|
« Last Edit: Sep 28th, 2004, 9:32am by Aryabhatta » |
IP Logged |
|
|
|
Sir Col
Uberpuzzler
impudens simia et macrologus profundus fabulae
Gender:
Posts: 1825
|
|
Re: Grimbal's Personalized Picture
« Reply #7 on: Sep 28th, 2004, 10:41am » |
Quote Modify
|
Give or take a bit, my guess... Code:$dirname="<path>"; $i=0; $dh=opendir($dirname); while ($f=readdir($dh)) { if (strstr($f,".gif")) { $a[$i]=$f; $i++; } } closedir($dh); $rn=time()%$i; print "<img src='$dirname/$a[$rn]' alt='' /><br />"; |
|
|
|
IP Logged |
mathschallenge.net / projecteuler.net
|
|
|
Sir Col
Uberpuzzler
impudens simia et macrologus profundus fabulae
Gender:
Posts: 1825
|
|
Re: Grimbal's Personalized Picture
« Reply #8 on: Sep 28th, 2004, 11:15am » |
Quote Modify
|
Okay, I abandon that theory. The following script (which waits 1 second between obtaining the next image) produces ten identical images: Code:for($j=1;$j<=10;$j++) { print "Testing $j<br />"; print "<img src='http://florian.net/pic/65x65/mypic.php' alt='' /><br />"; sleep(1); } |
|
|
|
IP Logged |
mathschallenge.net / projecteuler.net
|
|
|
towr
wu::riddles Moderator Uberpuzzler
Some people are average, some are just mean.
Gender:
Posts: 13730
|
|
Re: Grimbal's Personalized Picture
« Reply #9 on: Sep 28th, 2004, 12:42pm » |
Quote Modify
|
on Sep 28th, 2004, 9:31am, Aryabhatta wrote:I don't think most broswers would cache links which refer to scripts, though I am not sure. |
| Oh, but they do.. Espescially IE. Besides, the url is written thusly that most browsers won't readily recognize it as a script. (They recognize it as an image file with extention .gif) To avoid caching you need to use some four ways to dissuade the various browsers from caching it using http headers: Code:<?php // Date in the past header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // always modified header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // HTTP/1.1 header("Cache-Control: no-store, no-cache, must-revalidate"); header("Cache-Control: post-check=0, pre-check=0", false); // HTTP/1.0 header("Pragma: no-cache"); ?> |
|
|
|
IP Logged |
Wikipedia, Google, Mathworld, Integer sequence DB
|
|
|
towr
wu::riddles Moderator Uberpuzzler
Some people are average, some are just mean.
Gender:
Posts: 13730
|
|
Re: Grimbal's Personalized Picture
« Reply #10 on: Sep 28th, 2004, 12:49pm » |
Quote Modify
|
Try this in various browsers. In IE it gives me the same picture 7 times, in NS4.7 it gives me different ones, in firebird and opera again the same ones. Of course you can change options of your browser as well, with varying results..
|
« Last Edit: Sep 28th, 2004, 12:51pm by towr » |
IP Logged |
Wikipedia, Google, Mathworld, Integer sequence DB
|
|
|
Aryabhatta
Uberpuzzler
Gender:
Posts: 1321
|
|
Re: Grimbal's Personalized Picture
« Reply #11 on: Sep 28th, 2004, 12:59pm » |
Quote Modify
|
on Sep 28th, 2004, 12:49pm, towr wrote:Try this in various browsers. In IE it gives me the same picture 7 times, in NS4.7 it gives me different ones, in firebird and opera again the same ones. Of course you can change options of your browser as well, with varying results.. |
| Yes. I tried it with netscape with caching disabled and I got 7 different pics. This link gives 7 (maybe less) different pics in IE (depending on the random generator used) It is the same as what towr gave, but .gif replaced by 7,6,5,4,3,2,1.
|
« Last Edit: Sep 28th, 2004, 1:00pm by Aryabhatta » |
IP Logged |
|
|
|
Grimbal
wu::riddles Moderator Uberpuzzler
Gender:
Posts: 7527
|
|
Re: Grimbal's Personalized Picture
« Reply #12 on: Sep 28th, 2004, 2:25pm » |
Quote Modify
|
I don't think I am a script kiddie, at least not as per this definition. http://www.webopedia.com/TERM/S/script_kiddie.html I wrote the script *myself*. Sir Col's code won't work, because the URL must return a gif file, and not a piece of HTML that links to a gif file. I did not use REFERRER, because I don't care what picture shows where. I would have to use it if I wanted to use one picture per forum, but always the same picture within a forum. In my case, I just return any picture. In fact, how often it changes is just a matter of how often your browser thinks it needs to reload the image. Usually, if the same image is used multiple times on a page, the browser will load it once and display it so many times. Anyway, here is the code. It selects a random image file in the current directory, declares the returned data type as .gif format, and copy the binary file contents to the output. To the caller, (the browser), it exactly as if it retrieved a static .gif file. Code:<?php $files = array(); $i = 0; $dh = opendir("./"); while( ($file = readdir ($dh)) ){ if( substr($file,-4)==".gif" ){ $files[$i++] = $file; } } closedir($dh); $i = rand(0,count($files)-1); $file = $files[$i]; header('Content-type:image/gif'); $pic = file_get_contents($file); echo $pic; exit; ?> |
|
|
« Last Edit: Sep 28th, 2004, 2:29pm by Grimbal » |
IP Logged |
|
|
|
Marcello Toskana
Guest
|
|
Re: Grimbal's Personalized Picture
« Reply #13 on: Nov 5th, 2005, 1:44am » |
Quote Modify
Remove
|
Awesome! Thanks for the code I will now try to implement it. Looked a little complicated.. Greetz from Europe, Marcello Toskana
|
|
IP Logged |
|
|
|
|