Esempio n. 1
0
 /**
  * Get the item owner name
  */
 public function getOwner($default = '')
 {
     $path = $this->getPath();
     $output = '';
     if (file_exists($path)) {
         $uid = Utils::getValue(@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::getValue(@$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;
 }
Esempio n. 2
0
 /**
  * Adds an entry to the list of breadcrumb links data
  */
 public function addCrumb($name = '', $link = '', $title = '', $params = array())
 {
     $key = Sanitize::toKey($name);
     $name = Sanitize::toName($name);
     $link = Sanitize::toPath($link);
     $title = Sanitize::toTitle($title);
     if (!empty($key) && !empty($link)) {
         $crumbs = $this->get('crumbs', array());
         $crumbs[$key] = array_merge(array('name' => $name, 'link' => $link, 'title' => $title), $params);
         $this->set('crumbs', $crumbs);
     }
 }