zackcez Posted May 28, 2008 Share Posted May 28, 2008 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 More sharing options...
corbin Posted May 28, 2008 Share Posted May 28, 2008 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.