+ Reply to Thread
Results 1 to 4 of 4

Thread: Help with PHP is needed...

  1. #1
    dragoneye_xp's Avatar
    dragoneye_xp is offline x10 Sophmore dragoneye_xp is an unknown quantity at this point
    Join Date
    Oct 2005
    Location
    Texas
    Posts
    165

    Help with PHP is needed...

    I am trying to fix my LIST (and several other "command modules") for Pyro OS Command Shell so that users cannot go back any further than their user directories.

    I've tried this...

    PHP:
    Code:
    function inhome($path){
        global $passwd,$userhome,$userperms; //Password, user's home directory, and user's permission data in home directory.
        if(strpos($userhome.$path,$userhome)===false){ //If the path the user specified is NOT in the user's home directory...
            SendLn("//c:ff0000:Access is denied to //c//c:ffff00:".$path."//c"); //Output an error to the console.
            return false; //Tell the caller that the path the user specified was not found in his or her user directory.
        }
        return true; //Otherwise, tell the caller that the path was found in the user's directory.
    }
    ...but that's not working.

    Can anyone help me?

  2. #2
    careerbridge's Avatar
    careerbridge is offline x10 Sophmore careerbridge is an unknown quantity at this point
    Join Date
    Jun 2006
    Location
    India
    Posts
    126

  3. #3
    Bryon is offline Administrator Bryon has disabled reputation
    Join Date
    Apr 2005
    Location
    Northfield, NH
    Posts
    7,608

    Re: Help with PHP is needed...

    Do like he said above me, and echo, or even print_r() the variables.

    Also, one thing I notice is:
    PHP Code:
    if(strpos($userhome.$path,$userhome
    You're adding $path onto the end of $userhome, then checking for that in $userhome? Seems to me like it would also "never find it" and return a false value..

    Not sure though what they contain.

  4. #4
    dragoneye_xp's Avatar
    dragoneye_xp is offline x10 Sophmore dragoneye_xp is an unknown quantity at this point
    Join Date
    Oct 2005
    Location
    Texas
    Posts
    165

    Re: Help with PHP is needed...

    Never mind - I figured it out.
    Code:
    function inhome($path){
        global $passwd,$userhome,$userperms;
        SendLn($userhome.$path);
        if(strpos(realpath($userhome.$path),realpath($userhome))===false){
            SendLn("//c:ff0000:Access is denied to //c//c:ffff00:".$path."//c");
            return false;
        }
        return true;
    }
    That way if a users tries to do the ../../ thing, it won't go back no further than their user directory.

+ Reply to Thread

Similar Threads

  1. [PHP] Variables in PHP
    By Bryon in forum Tutorials
    Replies: 15
    Last Post: 01-29-2009, 09:46 AM
  2. tons of PHP Resources
    By Chris S in forum Scripts & 3rd Party Apps
    Replies: 10
    Last Post: 01-16-2009, 10:07 AM
  3. [PHP] PHP For Starters
    By Complex in forum Tutorials
    Replies: 24
    Last Post: 06-14-2008, 11:40 PM
  4. Unstand PHP?
    By o0slowpaul0o in forum Tutorials
    Replies: 8
    Last Post: 01-07-2008, 09:16 PM
  5. A Little bit of PHP help needed.
    By Sheepoholics in forum Scripts & 3rd Party Apps
    Replies: 5
    Last Post: 03-09-2006, 07:56 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers