Web Hosting Talk







View Full Version : Case sensitivity..


2399Skillz
03-11-2010, 04:10 AM
I have a script setup to pull data from a gaming server and display this data on the web page. The problem with this is sometime the case of the data being pulled might not be the same, for example.

I have it setup to pull the "face" that each player is using, then assign it to a JPG that will be displayed next to his/her name. Now the problem is, the case of each player might be different, depending on what version of the game they are using, but it's the same file. TSkMSkins.Firewall.jpg should be the same as tskmskins.Firewall.jpg but I do not want to have to upload the same file more than one time with different cases, so is there some way to use a .htaccess file that will tell Apache that tskmskins.Firewall.jpg and TSkMSkins.Firewall.jpg are the same file?

campolar
03-11-2010, 07:10 AM
I don't see how .htaccess stuff can be related to web design :S

amillerweb
03-12-2010, 04:01 PM
Ive never heard of file name transform using .htaccess?

2399Skillz
03-12-2010, 04:02 PM
Sorry, I didn't know of any other section to post this under.

If not using a .htaccess, is there some other way?

Driver01
03-12-2010, 04:15 PM
this would be a programming issue and you would use php if your script uses php that is?

bear
03-12-2010, 04:22 PM
*moved to programming*

You might try changing the case via the script:
http://php.net/manual/en/function.strtolower.php

2399Skillz
03-13-2010, 03:18 AM
Hey Bear,

Thanks for moving the topic to me. I am not that great at programming in PHP, so can someone help me with this?

<?
//Check if the skin faces are enabled. Only show if it's true (see config file)
If ($showskin == true)
{

$skinfile = "images/skins/" . getiteminfo("Face_" . $itemx,$chunks) . ".jpg";

if (file_exists($skinfile)) {
?>
<IMG SRC="<? echo $skinfile;?>" align="right">
<?
} else {
?>
<? echo $skinfile;?>
<?
}
}
?>

That's the code that returns the string that is fetched from a server.

This is how I think it needs to be done.

<?
//Check if the skin faces are enabled. Only show if it's true (see config file)
If ($showskin == true)
{

$skinfile = "images/skins/" . getiteminfo("Face_" . $itemx,$chunks) . ".jpg";

if (file_exists($skinfile)) {
?>
<? echo strtolower($skinfile);?>
<?
} else {
?>
<? echo $skinfile;?>
<?
}
}
?>

I tested it and it does seem to work but not all the results are lower case. Seems a few get by that aren't. :confused:

2399Skillz
03-13-2010, 03:20 AM
Nevermind, I figured it out.

<?
//Check if the skin faces are enabled. Only show if it's true (see config file)
If ($showskin == true)
{

$skinfile = "images/skins/" . getiteminfo("Face_" . $itemx,$chunks) . ".jpg";

if (file_exists($skinfile)) {
?>
<? echo strtolower($skinfile);?>
<?
} else {
?>
<? echo $skinfile;?>
<?
}
}
?>

The files that weren't lower case were being returned by the else statement. It all seems to work now guys, thanks so much.

2399Skillz
03-13-2010, 03:39 AM
Alright, I take that back.

The script does display the file names in lower case now, all of them.

However, even if the file does exist on the server, all lower case, it will not be displayed. Not sure why.

2399Skillz
03-13-2010, 03:44 AM
Sorry that I am talking to myself on here, just think of it as me writing my notes as I go along. Hehe

I found out the problem.

if (file_exists($skinfile)) {

It telling the script to look for the file, in the normal case that it receives it. Then when the script gets ready to display it, which is this line:

<IMG SRC="<? echo strtolower($skinfile);?>" align="right">

It's all in lower case, so it doesn't think the file exists an then goes onto the else statement. If I put the image code after the else statement, the images show up just fine. So... how can I add the strtolower function to this line:


if (file_exists($skinfile)) {

Would it be the obvious way?

2399Skillz
03-13-2010, 03:46 AM
Oh snap, it does work. This is the correct code, revised.

<?
//Check if the skin faces are enabled. Only show if it's true (see config file)
If ($showskin == true)
{

$skinfile = "images/skins/" . getiteminfo("Face_" . $itemx,$chunks) . ".jpg";

if (file_exists(strtolower($skinfile))) {
?>
<IMG SRC="<? echo strtolower($skinfile);?>" align="right">
<?
} else {
?>
<? echo strtolower($skinfile);?>
<?
}
}
?>

Joe262
03-14-2010, 12:21 PM
so is there some way to use a .htaccess file that will tell Apache that tskmskins.Firewall.jpg and TSkMSkins.Firewall.jpg are the same file?

uh, mod_rewrite

easiest way imho would be to convert the real file name to lowercase, and then use a mod_rewrite to make sure that no matter how the http request is sent, its seen as all lowercase for those files.

imho using a php script would be overkill.

mod_rewrite would have the added advantage that even if something other than a php script is referencing the jpg, it will still work.

2399Skillz
03-14-2010, 03:24 PM
uh, mod_rewrite

easiest way imho would be to convert the real file name to lowercase, and then use a mod_rewrite to make sure that no matter how the http request is sent, its seen as all lowercase for those files.

imho using a php script would be overkill.

mod_rewrite would have the added advantage that even if something other than a php script is referencing the jpg, it will still work.

I assumed there was a way with .htaccess, but I wasn't sure on how. The PHP way seems to work just fine though. :)

Morris Robin
03-18-2010, 06:38 AM
I am don't know about this type of PHP file. But is it possible to in game program to shift one of another. Please, let me know for all this query and with solution.

Thanks,
Morris