#1
  1. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2007
    Location
    Glendale AZ
    Posts
    230
    Rep Power
    96

    [Moved from PHP to IIS] Not sure if this is a PHP or IIS issue...


    I've got an intranet site I've been trying to get operational again and I am unable to get a PHP page to read a TXT file but since the PHP forum is the only place I usually go I'll start here...

    PHP Code:
    //$proofLog = "z:\administrative stuff\prooflog\outgoing proof log new.txt";
    $proofLog "p:\outgoing proof log new.txt"
    Z is a network share. P is a local drive. Reading the file on the local drive works, network drive does not.

    I can obviously read the file from the network share and I can also type that location in the URL field and it displays it in the browser.

    As with most of my issues I'm sure it's a simple solution but I'm not sure where to go from here.

    Thoughts?

    Mike
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jul 2003
    Posts
    4,350
    Rep Power
    630
    As a guess it might be the spaces in the network share name. Try adding single quotes inside the double quotes.
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  4. #3
  5. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2007
    Location
    Glendale AZ
    Posts
    230
    Rep Power
    96
    Tried the single quotes with no luck. Also tried to move the file to a new share without spaces "z:\prooflog\outgoing_proof_log_new.txt" and it wouldn't work, either. Of course, just copying that into the URL field opens the file in the browser just fine.
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Apr 2009
    Posts
    2,232
    Rep Power
    1296
    Post the code that is used to read the file and make sure you post enough of the code to show the full context of its usage.
  8. #5
  9. No Profile Picture
    Grumpier old Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jun 2003
    Posts
    14,553
    Rep Power
    4549
    Unless it's changed in recent years (haven't used IIS since IIS6), IIS by default operated under a user account local to the computer it's running on, and won't have any permissions to a network share unless you manually add permissions.
    ======
    Doug G
    ======
    I've never been able to appreciate the sublime arrogance of folks who feel they were put on earth just to save other folks from themselves .." - Donald Hamilton
  10. #6
  11. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2007
    Location
    Glendale AZ
    Posts
    230
    Rep Power
    96
    Originally Posted by FishMonger
    Post the code that is used to read the file and make sure you post enough of the code to show the full context of its usage.
    PHP Code:
    if (file_exists($proofLog) AND is_readable($proofLog)) {
        
    $proofList file($proofLog);
        for (
    $i 0$i count($proofList); $i++) {
              
    $tmp explode("\t"$proofList[$i]);
                  
    $temp_cutoff_date strtotime($tmp[4]);
                 if (
    $temp_cutoff_date >= $cutoff_unix_date) {
                  
    $proofListed[$i] = array(
                
    'order' => $tmp[0], 
                
    'sender' => $tmp[1], 
                
    'mainline' => $tmp[2], 
                
    'email' => $tmp[3], 
                
    'date' => $tmp[4], 
                
    'time' => $tmp[5], 
                
    'message' => rtrim($tmp[6]));
               }
        }
    }
    else {
    $note[] = "The Prooflog is missing or could not be read.";} 
    The code works on the local file so I can't imagine it's the code. But, since I know slightly more about PHP than I do IIS I started here...

    Originally Posted by Doug G
    Unless it's changed in recent years (haven't used IIS since IIS6), IIS by default operated under a user account local to the computer it's running on, and won't have any permissions to a network share unless you manually add permissions.
    I looked through the settings but wasn't looking for user accounts. I was looking for filetypes, specifically TXT. I'll go back through and see if I can find anything else...
  12. #7
  13. Not An Expert
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2015
    Posts
    404
    Rep Power
    3
    I'll keep an eye on this one - let me know if you want it moved to our IIS section!

    You could start a new thread in IIS, too, once the time comes - just close this one and link back to it in your new post. I think it's fine here for now while you explore the issue.

    I'm afraid I won't be of much help otherwise, but best of luck with it!
  14. #8
  15. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2007
    Location
    Glendale AZ
    Posts
    230
    Rep Power
    96
    Originally Posted by markroberts
    I'm afraid I won't be of much help otherwise, but best of luck with it!
    Thanks, gonna need it. I'm afraid I just blew up our intranet. Nothing loads now. Had to go back to a previous backup which was likely before this site was on it so nothing loads Good thing not many people use it
  16. #9
  17. No Profile Picture
    Super Moderator
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Jun 2009
    Location
    Hartford, WI
    Posts
    1,494
    Rep Power
    111
    As far as the browser you are using, and the IIS server goes, they are both on the same computer, correct? Have you attempted to access the network item via a network path ('\\ComputerName\foldername\filename.ext') instead of the mounted Z:? When attempting to access it over the network, are there any errors left in the PHP or IIS/domain error log? Turn all your errors on for the troubleshooting, if not already.
    He who knows not that he knows not is a fool, ignore him. He who knows that he knows not is ignorant, teach him. He who knows not that he knows is asleep, awaken him. He who knows that he knows is a leader, follow him.
  18. #10
  19. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2007
    Location
    Glendale AZ
    Posts
    230
    Rep Power
    96
    Originally Posted by Triple_Nothing
    As far as the browser you are using, and the IIS server goes, they are both on the same computer, correct? Have you attempted to access the network item via a network path ('\\ComputerName\foldername\filename.ext') instead of the mounted Z:? When attempting to access it over the network, are there any errors left in the PHP or IIS/domain error log? Turn all your errors on for the troubleshooting, if not already.
    I can access the file fine using the network path.

    Talked with one of our IT people and they confirmed that "Since the application is trying to read/write to a file which is on another server, IIS tries to authenticate against that server with a local account which fails". He has an idea and gave me a link to a MS page that talks about virtual directories (https://support.microsoft.com/en-us/kb/207671) but I haven't read through it yet...

    Originally Posted by markroberts
    I'll keep an eye on this one - let me know if you want it moved to our IIS section!
    Yeah, you can move this to IIS, Mark. Thanks!

    Comments on this post

    • Will-O-The-Wisp agrees : Ok, I've moved it! If you have an idea for a more descriptive title, feel free to PM me with it and I can change that too if you like!
  20. #11
  21. No Profile Picture
    Super Moderator
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Jun 2009
    Location
    Hartford, WI
    Posts
    1,494
    Rep Power
    111
    If you are familiar with the login credentials, is this helpful in any way?
    PHP Code:
    <?php

    // Define the parameters for the shell command
    $location "\\servername\sharename";
    $user "USERNAME";
    $pass "PASSWORD";
    $letter "Q";

    // Map the drive
    system("net use ".$letter.": \"".$location."\" ".$pass." /user:".$user." /persistent:no>nul 2>&1");

    // Open the directory
    $dir opendir($letter.":/an/example/path")

    ...

    ?>
    There are also 2 other easy options, if permitted.
    1.) Adjust the user in which the web server runs as to one with permissions to the network folder.
    2.) Add the user in which the server runs under to the shared side to grant it.
    Last edited by Triple_Nothing; June 4th, 2015 at 07:04 PM.
    He who knows not that he knows not is a fool, ignore him. He who knows that he knows not is ignorant, teach him. He who knows not that he knows is asleep, awaken him. He who knows that he knows is a leader, follow him.
  22. #12
  23. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2007
    Location
    Glendale AZ
    Posts
    230
    Rep Power
    96
    I'd thought about adding the user on the file server but I didn't know how they are meant to work, maybe special permissions (wouldn't want to give it too much power), nor did I know the password, so I didn't try that. Yet...
  24. #13
  25. No Profile Picture
    Grumpier old Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jun 2003
    Posts
    14,553
    Rep Power
    4549
    In the olden days, I used to just add the IIS user account to the target server's user base, but it was always in a private protected network, so I don't know about any other security implications of doing this.
    ======
    Doug G
    ======
    I've never been able to appreciate the sublime arrogance of folks who feel they were put on earth just to save other folks from themselves .." - Donald Hamilton

IMN logo majestic logo threadwatch logo seochat tools logo