lamorra Posted May 23, 2009 Share Posted May 23, 2009 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! Quote Link to comment https://forums.phpfreaks.com/topic/159401-solved-blahpng-to-run-php-script/ Share on other sites More sharing options...
Axeia Posted May 23, 2009 Share Posted May 23, 2009 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/ Quote Link to comment https://forums.phpfreaks.com/topic/159401-solved-blahpng-to-run-php-script/#findComment-840799 Share on other sites More sharing options...
lamorra Posted May 23, 2009 Author Share Posted May 23, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/159401-solved-blahpng-to-run-php-script/#findComment-840800 Share on other sites More sharing options...
Axeia Posted May 23, 2009 Share Posted May 23, 2009 Then look at the second link, the checking if it exists part is simply file_exists Quote Link to comment https://forums.phpfreaks.com/topic/159401-solved-blahpng-to-run-php-script/#findComment-840805 Share on other sites More sharing options...
lamorra Posted May 23, 2009 Author Share Posted May 23, 2009 The problem with that is, most forums wont allow images like that. That's why I need it to create and display the image if it doesn't exist, and if it does exist, just display the image. Quote Link to comment https://forums.phpfreaks.com/topic/159401-solved-blahpng-to-run-php-script/#findComment-840809 Share on other sites More sharing options...
.josh Posted May 23, 2009 Share Posted May 23, 2009 suppose you could make your script that parses the blah in blah.jpg and creates the image, and then make that script your custom 404 page. Quote Link to comment https://forums.phpfreaks.com/topic/159401-solved-blahpng-to-run-php-script/#findComment-840863 Share on other sites More sharing options...
kickstart Posted May 23, 2009 Share Posted May 23, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/159401-solved-blahpng-to-run-php-script/#findComment-840879 Share on other sites More sharing options...
razta Posted May 23, 2009 Share Posted May 23, 2009 I posted about something similar on my blog, you may be able to use the method I talk about if I understand what your trying to do correctly. http://www.ethicalhack3r.co.uk/2009/03/15/using-a-web-bug-for-information-gathering/ Quote Link to comment https://forums.phpfreaks.com/topic/159401-solved-blahpng-to-run-php-script/#findComment-840903 Share on other sites More sharing options...
kickstart Posted May 23, 2009 Share Posted May 23, 2009 Hi Very interesting. All the best Keith Quote Link to comment https://forums.phpfreaks.com/topic/159401-solved-blahpng-to-run-php-script/#findComment-840909 Share on other sites More sharing options...
RussellReal Posted May 23, 2009 Share Posted May 23, 2009 dude.. all these posters are dummies.. do this make a file called .htaccess and inside the .htaccess put RewriteEntine on RewriteRule ^blah.png$ blah.php and inside blah.php put the image generation code.. Quote Link to comment https://forums.phpfreaks.com/topic/159401-solved-blahpng-to-run-php-script/#findComment-840925 Share on other sites More sharing options...
Ken2k7 Posted May 23, 2009 Share Posted May 23, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/159401-solved-blahpng-to-run-php-script/#findComment-840935 Share on other sites More sharing options...
RussellReal Posted May 23, 2009 Share Posted May 23, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/159401-solved-blahpng-to-run-php-script/#findComment-840936 Share on other sites More sharing options...
Ken2k7 Posted May 23, 2009 Share Posted May 23, 2009 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. Well I like my RewriteConds. You're right that it's a bit excessive. Quote Link to comment https://forums.phpfreaks.com/topic/159401-solved-blahpng-to-run-php-script/#findComment-840941 Share on other sites More sharing options...
lamorra Posted May 24, 2009 Author Share Posted May 24, 2009 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... Quote Link to comment https://forums.phpfreaks.com/topic/159401-solved-blahpng-to-run-php-script/#findComment-841407 Share on other sites More sharing options...
lamorra Posted May 24, 2009 Author Share Posted May 24, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/159401-solved-blahpng-to-run-php-script/#findComment-841417 Share on other sites More sharing options...
RussellReal Posted May 25, 2009 Share Posted May 25, 2009 !-f is if the file doesn't exist Quote Link to comment https://forums.phpfreaks.com/topic/159401-solved-blahpng-to-run-php-script/#findComment-841539 Share on other sites More sharing options...
lamorra Posted May 25, 2009 Author Share Posted May 25, 2009 I know that, but since it the file name wont be changed until the PHP script is ran, I'm wondering if it will still try to create. Quote Link to comment https://forums.phpfreaks.com/topic/159401-solved-blahpng-to-run-php-script/#findComment-841598 Share on other sites More sharing options...
kickstart Posted May 25, 2009 Share Posted May 25, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/159401-solved-blahpng-to-run-php-script/#findComment-841671 Share on other sites More sharing options...
lamorra Posted May 25, 2009 Author Share Posted May 25, 2009 It would redirect to path/to/file.php?username=blah Quote Link to comment https://forums.phpfreaks.com/topic/159401-solved-blahpng-to-run-php-script/#findComment-841824 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.