/** * @param bool $isPersonal * @return bool */ public function test($isPersonal = true) { if ($isPersonal) { if ($this->stat('')) { return true; } return false; } else { $smb = new \smb(); $pu = $smb->parse_url($this->constructUrl('')); // Attempt to connect anonymously $pu['user'] = ''; $pu['pass'] = ''; // Share cannot be checked if dynamic if ($this->username_as_share) { if ($smb->look($pu)) { return true; } else { return false; } } if (!$pu['share']) { return false; } // The following error messages are expected due to anonymous login $regexp = array('(NT_STATUS_ACCESS_DENIED)' => 'skip') + $smb->getRegexp(); if ($smb->client("-d 0 " . escapeshellarg('//' . $pu['host'] . '/' . $pu['share']) . " -c exit", $pu, $regexp)) { return true; } else { return false; } } }
function stream_stat() { return smb::url_stat($this->url); }
private function getStream() { if (isset($this->stream)) { return $this->stream; } if (isset($this->defer_stream_read)) { $this->tmpfile = tempnam(SMB4PHP_SMBTMP, 'smb.down'); self::debug("Creating real tmp file now"); smb::execute('get "' . $this->parsed_url['path'] . '" "' . $this->tmpfile . '"', $this->parsed_url); $this->stream = fopen($this->tmpfile, $this->mode); } return $this->stream; }