Jump to content

Get path to a file when directory name in unknown


ffmus123

Recommended Posts

Hello fellow php users.

 

I am trying to read the contents of a Local Shared Object file (.sol) stored in Application Data.

The problem is that one of the directories is named with a random string which is different for each user.

For example I am trying to read the file info.sol stored in %APPDATA%\Macromedia\Flash Player\#SharedObjects\[random string]\mywebsite.com\info.sol . The environment variable %APPDATA% points to C:\Users\Username\AppData\Roaming\ on my machine, however I am not sure if php can use windows environment variables?

 

I have tried using readdir() and scandir() functions with the %APPDATA% path to try and find the name of the 'random string' directory however php doesn't seem to recognise the path

$dir = "%APPDATA%/Macromedia/Flash Player/#SharedObjects/";
$dh = opendir($dir);
$first = readdir($dh);
echo $first;

 

If php can't use the %APPDATA% path then I will have to use the same method to bypass the random username directory as I do for the 'random string' directory, I just don't know how I can get this working.

 

This is all so I can make a php score display page to read info.sol which is created by a flash game on my site.

Many thanks.

Use getenv and glob.

print_r(glob(getenv("APPDATA") . "\\Macromedia\\Flash Player\\#Shared Objects\\*\\mywebsite.com\\info.sol"));

 

Thank you, i'm suprised I didn't find the getenv() function through searching. However the path it returns is not the same as the path when doing cd %APPDATA% in command prompt. It seems to go to the system appdata profile. Anyway to get the users appdata?

Thank you, i'm suprised I didn't find the getenv() function through searching. However the path it returns is not the same as the path when doing cd %APPDATA% in command prompt. It seems to go to the system appdata profile. Anyway to get the users appdata?

You probably have PHP running as a system user (NETWORK SERVICE I think), and probably because it's in IIS or Apache which is running as a service. It doesn't know about other users, least of all not who "you" are.

 

Just hardcode the path.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.