예제 #1
0
 /**
  * Get the item owner name
  */
 public function getOwner($default = "")
 {
     $path = $this->getPath();
     $output = "";
     if (file_exists($path)) {
         $uid = Utils::value(@fileowner($path), 0);
         // try from cache
         if (empty($output) && !empty($this->_cache["username"][$uid])) {
             $output = $this->_cache["username"][$uid];
         }
         // try using posix_getpwuid
         if (empty($output) && function_exists("posix_getpwuid")) {
             $pwuid = @posix_getpwuid($uid);
             $output = Utils::value(@$pwuid["name"], "");
             $output = Sanitize::toName($output);
         }
         // try using system stat command
         if (empty($output) && function_exists("system")) {
             @ob_start();
             @system("stat -c %U " . $path);
             $output = Sanitize::toName(@ob_get_clean());
         }
         // try using system ls command
         if (empty($output) && function_exists("system")) {
             @ob_start();
             @system("ls -ld " . $path);
             @(list(, , $output, ) = explode(" ", @ob_get_clean(), 4));
             $output = Sanitize::toName($output);
         }
     }
     if (!empty($output)) {
         $this->_cache["username"][$uid] = $output;
         return $output;
     }
     return $default;
 }