| SpecialAttack.net https://forum.specialattack.net/ |
|
| Random Avatars via PHP (HALP!) https://forum.specialattack.net/viewtopic.php?t=7150 |
Page 1 of 1 |
| Author: | Lim-Dul [ 31 Mar 2010, 01:17 ] |
| Post subject: | Random Avatars via PHP (HALP!) |
So, to all you PHP wizards out there, I have a question. I've made a little script that will rotate avatars and disguise itself as a PNG (of course I have .htaccess with a rewrite rule for that as well) but for some reason it won't work on the forums. That is, it will correctly display the images if linked to as .php but not .png. What's the problem? Code:
Code:
Code:
![]() :-( P.S. It works as a link in the browser itself: http://limdul.byethost11.com/Chibi_Bloo ... random.png P.P.S. Here's my .htaccess Code:
P.P.P.S. A-ha! The script isn't redirected properly unless typed in manually in the browser. I guess I have to do something more with the rewrite engine?
|
|
| Author: | Lim-Dul [ 31 Mar 2010, 04:16 ] |
| Post subject: | Re: Random Avatars via PHP (HALP!) |
Mystery solved - the bad host didn't support image hotlinking. I wish I could have used mine but the server doesn't support URL rewriting for security reasons. :-P Now I have a dynamically generated avatar which will be my MSPaint emblem 50% of the time and one of the Bloodline Champion Chibi avatars the other 50%. :-D Code:
|
|
| Author: | [SpA]Frosty [ 31 Mar 2010, 21:03 ] |
| Post subject: | Re: Random Avatars via PHP (HALP!) |
[SpA]Lim-Dul wrote: I wish I could have used mine but the server doesn't support URL rewriting for security reasons.
Never knew mod_rewrite was such a big security problem |
|
| Author: | Lim-Dul [ 31 Mar 2010, 21:10 ] |
| Post subject: | Re: Random Avatars via PHP (HALP!) |
Nah, .htaccess work just fine (except for some functions). Anyways, it's sorted. ^^ |
|
| Author: | BigBadaBoom [ 01 Apr 2010, 08:41 ] |
| Post subject: | Re: Random Avatars via PHP (HALP!) |
Do you plan on modifying the image? If you're not then instead of creating an image in memory from png and then converting it to png and outputting it I'd suggest using Code:
Reads a file and writes it to the output buffer.
|
|
| Author: | Lim-Dul [ 01 Apr 2010, 08:47 ] |
| Post subject: | Re: Random Avatars via PHP (HALP!) |
BigBadaBoom wrote: Do you plan on modifying the image?
How would that affect the browser cache? I mean, wouldn't not recreating (and destroying) the image stop it from being updated on each request?
If you're not then instead of creating an image in memory from png and then converting it to png and outputting it I'd suggest using Code:
Reads a file and writes it to the output buffer. |
|
| Author: | BigBadaBoom [ 01 Apr 2010, 09:03 ] |
| Post subject: | Re: Random Avatars via PHP (HALP!) |
The browser doesn't see a difference. Its just how it works internally in the server. Btw, you can effect the browser cache using the head: Code:
This stops all browsers or any proxys (proxys like to cache to reduce traffic) from caching the image.
|
|
| Author: | Lim-Dul [ 01 Apr 2010, 09:16 ] |
| Post subject: | Re: Random Avatars via PHP (HALP!) |
BigBadaBoom wrote: The browser doesn't see a difference. Its just how it works internally in the server.
Thanks! That's the kind of expert advice I was looking for. I use PHP only on a need-to-know basis. =)Btw, you can effect the browser cache using the head: Code:
This stops all browsers or any proxys (proxys like to cache to reduce traffic) from caching the image.The updated code works like a charm even without cache-affecting header tags and while functionally speaking there's no difference it's certainly a more elegant way to do it - especially if I were to ever write a larger script and needed to optimize it for speed. :-D Code:
|
|
| Page 1 of 1 | All times are UTC+01:00 |
|
Powered by phpBB® Forum Software © phpBB Limited |
|