Jump to content

Recommended Posts

I have this code:

<?php 

$bd_host = "";     // Database host
$bd_usuario = "";       // Database username
$bd_password = "";      // Database password
$bd_base = "";            // Database name
$con = mysql_connect($bd_host, $bd_usuario, $bd_password); mysql_select_db($bd_base, $con);



$user = $_GET['name'];
$sql = "SELECT * FROM user WHERE pet_name='$user'";
$result = mysql_query($sql);
$row = mysql_fetch_array($result);



$level = $row["level"];

$pet_name = $row["pet_name"];

$color = $row["color"];
$browser = $_SERVER['HTTP_USER_AGENT'];
$realip = isset($_SERVER['HTTP_X_FORWARDED_FOR']) ?
$_SERVER['HTTP_X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR'];

if($level <= 26){
$back = "http://deluzion-gaming.net/pixelplushies/pets/1to25_$color.jpg";
} elseif($level <= 76){
$back = "http://deluzion-gaming.net/pixelplushies/pets/26to75_$color.jpg";
} elseif($level <= 125){
$back = "http://deluzion-gaming.net/pixelplushies/pets/76to125_$color.jpg";
} elseif($level >= 125){
$back = "http://deluzion-gaming.net/pixelplushies/pets/126up_$color.jpg";
}else {
$back = "http://deluzion-gaming.net/pixelplushies/pets/erorr.jpg";
}
header ("Content-type: image/Jpeg");

$back = imagecreatefromjpeg ("$back");

$textcolor = imagecolorallocate($back, 255, 255, 255);
ImageString ($back, 5, 2, 1, "$pet_name", $textcolor);
ImageString ($back, 2, 65, 15, "Pet Level: $level", $textcolor);
ImageString ($back, 2, 65, 27, "Your IP: $realip", $textcolor);
ImageString ($back, 2, 65, 39, "Your Broser: $browser", $textcolor);
ImageJpeg ($back);
ImageDestroy ($back);
//UPDATE VIEW/LEVEL
$new_level = $row["level"]+1;
mysql_query("UPDATE user SET level='$new_level' WHERE pet_name='$pet_name'");
//END OF UPDATE
?> 

It is currently viewed like this:

http://myurl/image.php?name=name

I KNOW this is possible...I want it to be usable like this:

http://myurl/image/name.jpg

I'm not at all sure how to do this though...any ideas are appreciated!

Link to comment
https://forums.phpfreaks.com/topic/107565-another-quick-php-gd/
Share on other sites

It can be done multiple ways.....

 

mod_rewrite....

 

Or, if mod_rewrite isn't allowed, you could use a custom 404 page for the image directory (kills your error logs practicality).

 

This is an example mod_rewrite config that you could put in a .htaccess file in your web root.

 

RewriteEngine on

RewriteRule ^image/([^/]+)\.jpg$ image.php?name=$1 [L]

 

Hrmm....  Did that in 2 seconds, so it might not be right.

Link to comment
https://forums.phpfreaks.com/topic/107565-another-quick-php-gd/#findComment-551452
Share on other sites

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.