2009-11-01 3 views

답변

1

이것은 내가 그것을 어떻게입니다 : true 또는 false를 반환하고, 또한 POST 값으로 인수 $ 사용자 이름을 무시

class goDirAlias 
{ 
    private function home_dir() 
    { 
     // Try to find out the home directory of the user running this script 
     if(function_exists("posix_getpwnam")) 
     { 
      // using posix 
      $user_info = posix_getpwnam(goDirAlias::whoami()); 
      $home_dir = $user_info['dir']."/"; 
     } else 
     { 
      // Looking for Windows environment variables 
      $home_dir = getenv('HOMEDRIVE').getenv('HOMEPATH').'\\'; 
      if($home_dir == "\\") 
      { 
       // Looking for *nix environment variables 
       $home_dir = getenv('HOME')."/"; 
      } 
     } 

    return $home_dir; 
    } 

    private function whoami() 
    { 
     // Try to find out the username of the user running the script 
     if(function_exists('posix_getpwuid')) 
     { 
      // using posix 
      $user_info = posix_getpwuid(posix_geteuid()); 
      $running_user = $user_info['name']; 
     } else { 
      // Looking for Windows environment variables 
      $running_user = getenv('USERNAME'); 
      if(empty($running_user)) 
      { 
       // Running *nix whoami 
       $running_user = exec('whoami'); 
      } 
     } 

    return $running_user; 
    } 
} 
+0

그게 내가 무엇을 찾고 있었는지 정확히! 고마워. 세바스찬. – Castro

-1

Linux에서 시도해 볼 수 있습니다.

function get_home_user($username) 
{ 
$username=$_POST["username"]; 
if (!empty($username))     
{ if(exec ("test (home/$username)")) 
    return true; 
} 
return false; 
} 
+0

. 나쁜 것 같아. 어쨌든 고마워! !. – Castro

+0

죄송합니다 그것은 진실하거나 거짓을 반환해야합니다 죄송합니다 괜찮아요 – streetparade

관련 문제