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.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

Link to comment
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.