示例#1
0
 function url_stat($url, $flags = STREAM_URL_STAT_LINK)
 {
     if ($s = smb::getstatcache($url)) {
         return $s;
     }
     list($stat, $pu) = array(false, smb::parse_url($url));
     switch ($pu['type']) {
         case 'host':
             if ($o = smb::look($pu)) {
                 $stat = stat("/tmp");
             } else {
                 trigger_error("url_stat(): list failed for host '{$pu['host']}'", E_USER_WARNING);
             }
             break;
         case 'share':
             if ($o = smb::look($pu)) {
                 $found = FALSE;
                 $lshare = strtolower($pu['share']);
                 # fix by Eric Leung
                 foreach ($o['disk'] as $s) {
                     if ($lshare == strtolower($s)) {
                         $found = TRUE;
                         $stat = stat("/tmp");
                         break;
                     }
                 }
                 if (!$found) {
                     trigger_error("url_stat(): disk resource '{$lshare}' not found in '{$pu['host']}'", E_USER_WARNING);
                 }
             }
             break;
         case 'path':
             if ($o = smb::execute('dir "' . $pu['path'] . '"', $pu)) {
                 $p = explode('\\', $pu['path']);
                 $name = $p[count($p) - 1];
                 if (isset($o['info'][$name])) {
                     $stat = smb::addstatcache($url, $o['info'][$name]);
                 } else {
                     trigger_error("url_stat(): path '{$pu['path']}' not found", E_USER_WARNING);
                 }
             } else {
                 return false;
                 // 					trigger_error ("url_stat(): dir failed for path '{$pu['path']}'", E_USER_WARNING);
             }
             break;
         default:
             trigger_error('error in URL', E_USER_ERROR);
     }
     return $stat;
 }
示例#2
0
文件: smb.php 项目: rmxcc/pydio-core
 public function url_stat($url, $flags = STREAM_URL_STAT_LINK)
 {
     global $__count;
     if ($s = smb::getstatcache($url)) {
         self::debug("Using statcache for {$url}");
         return $s;
     }
     self::debug("Getting statcache for {$url}");
     //self::debug("Hey: " $url['user']);
     list($stat, $pu) = array(array(), smb::parse_url($url));
     switch ($pu['type']) {
         case 'host':
             if ($o = smb::look($pu)) {
                 //self::debug($_SESSION["AJXP_SESSION_REMOTE_USER"]);
                 $stat = stat(SMB4PHP_SMBTMP);
             } else {
                 trigger_error("url_stat(): list failed for host '{$host}'", E_USER_WARNING);
             }
             break;
         case 'share':
             if ($_SESSION["COUNT"] == 0) {
                 $_SESSION["COUNT"] = 1;
                 //self::debug("OH HEY");
                 //$__count++;
                 //self::debug($__count);
                 if ($o = smb::look($pu)) {
                     $_SESSION["disk"] = $o['disk'];
                     self::debug(print_r($_SESSION["disk"], true));
                     //self::debug(print_r($_ENV, true));
                     $found = FALSE;
                     $lshare = strtolower($pu['share']);
                     # fix by Eric Leung
                     if (is_array($o) && isset($o['disk']) && is_array($o['disk'])) {
                         foreach ($o['disk'] as $s) {
                             if ($lshare == strtolower($s)) {
                                 $found = TRUE;
                                 //self::debug("DISK: " . $s);
                                 $stat = stat(SMB4PHP_SMBTMP);
                                 break;
                             }
                         }
                     }
                     if (!$found) {
                         //trigger_error ("url_stat(): disk resource '{$share}' not found in '{$host}'", E_USER_WARNING);
                         return null;
                     }
                 }
                 break;
             } else {
                 //self::debug($__count);
                 //self::debug("WORKING");
                 $found = FALSE;
                 $lshare = strtolower($pu['share']);
                 # fix by Eric Leung
                 if (is_array($_SESSION["disk"]) && isset($_SESSION["disk"]) && is_array($_SESSION["disk"])) {
                     foreach ($_SESSION["disk"] as $s) {
                         if ($lshare == strtolower($s)) {
                             $found = TRUE;
                             //self::debug("oh boy");
                             $stat = stat(SMB4PHP_SMBTMP);
                             break;
                         }
                     }
                 }
                 if (!$found) {
                     //trigger_error ("url_stat(): disk resource '{$share}' not found in '{$host}'", E_USER_WARNING);
                     return null;
                 }
                 break;
             }
         case 'path':
             //self::debug('before exe'.print_r($pu, true));
             $o = smb::execute('dir "' . $pu['path'] . '"', $pu);
             if ($o != null) {
                 if ($o == "NOT_FOUND") {
                     return null;
                 }
                 $p = explode("\\", $pu['path']);
                 $name = $p[count($p) - 1];
                 if (isset($o['info'][$name])) {
                     $stat = smb::addstatcache($url, $o['info'][$name]);
                 } else {
                     $stat = stat(SMB4PHP_SMBTMP);
                     //trigger_error ("url_stat(): path '{$pu['path']}' not found", E_USER_WARNING);
                 }
             } else {
                 //$stat = stat(SMB4PHP_SMBTMP);
                 trigger_error("url_stat(): dir failed for path '{$pu['path']}'", E_USER_WARNING);
             }
             break;
         default:
             trigger_error('error in URL', E_USER_ERROR);
     }
     return $stat;
 }