Jump to content

Recommended Posts

I want users to be able to do like "http://site.com/sigs/theirusernamehere.png" and a PHP script is ran that takes the name they put before the .png if the image doesn't already exist.

 

I am guessing I'm going to need to use a .htaccess along with PHP, but I have no clue how to make it happen. I do know how to make the image and put their name on it.

 

Any help would be awesome!

Link to comment
https://forums.phpfreaks.com/topic/159401-solved-blahpng-to-run-php-script/
Share on other sites

http://us.php.net/manual/en/function.imagestring.php for the image part, I suggest you get it working off a normal $_GET first, then later on if you want to use .htaccess to create  an url without any ? & stuff in it you can have a look at

http://www.sitepoint.com/article/search-engine-friendly-urls/

I already know how to make images. I want the user to be able to go to "http://example.com/directory/sigs/BLAH.png" and if BLAH.png isn't created, create it. If it is, output the image.

 

Meaning, I don't want people to have to go to some other page, fill out a form/send variablesthrough the URL, and then it generates an image. I want the code to grab the BLAH part of the BLAH.png and create a sig based on that. I know it can be done, I've seen it before. I just can't think of how to go about doing this.

Hi

 

While many forums will not accept a php script as an image, fair chance that they use fairly crude checks. You might well get away with something like "http://site.com/sigs/generateimagescript.php?image=theirusernamehere.png" .

 

All the best

 

Keith

RussellReal: check your typos.

 

Try this -

Options +FollowSymLinks
RewriteEngine on
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} ^.*\.png$
RewriteRule ([a-zA-Z]+)\.png$ path/to/file.php?username=$1

I assume their name has only letters.

oh yeah, RewriteEngine, no he doesn't need the conds, if the regex is looking for .png

 

RewriteEngine on
RewriteRule ^blah.png$ blah.php

 

well, okay, the first rewrite cond, could be useful, but the second one is excessive :)

Thanks for the replies, sorry for the long response time...

 

Anyways, I used Ken2k7's way since he is spot on to what I'm trying to do (as well as RusselReal). Thanks for all of your help, didn't imagine it would mostly deal with the .htaccess...

 

 

Ahh last minute question.

 

With this part:

RewriteCond %{REQUEST_FILENAME} !-f

 

Will that make the image creation script run again if I allowed _ and - in the name? Like "blah-1.png" creates the image, then they go to "blah_1.png"? I am going to allow those 2 characters in their names, and will just replace one for the other in when the image saves.

Hi

 

Having only briefly played with .htaccess (and then having problems with it being inconsistant, as though it was cached), can I ask a quick question about this:-

 

Options +FollowSymLinks
RewriteEngine on
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} ^.*\.png$
RewriteRule ([a-zA-Z]+)\.png$ path/to/file.php?username=$1

 

Do I take it the first RewriteCond checks the file (say, Blah.png) exists, while the 2nd checks that the requested file is a png file? Also I take it that if both these conditions are met then the RewriteRule is invoked, and that would do take a requested file of blah.png and redirect to path/to/file.php?username=blah, or path/to/file.php?username=blah.png?

 

Thanks as this is useful.

 

All the best

 

Keith

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.