Esempio n. 1
0
 /**
  * @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;
         }
     }
 }
Esempio n. 2
0
 function stream_open($url, $mode, $options, $opened_path)
 {
     $this->url = $url;
     $this->mode = $mode;
     $this->parsed_url = $pu = smb::parse_url($url);
     if ($pu['type'] != 'path') {
         trigger_error('stream_open(): error in URL', E_USER_ERROR);
     }
     switch ($mode) {
         case 'r':
         case 'r+':
         case 'rb':
         case 'a':
         case 'a+':
             $this->tmpfile = tempnam('/tmp', 'smb.down.');
             $result = smb::execute('get "' . $pu['path'] . '" "' . $this->tmpfile . '"', $pu);
             if ($result === false) {
                 return $result;
             }
             break;
         case 'w':
         case 'w+':
         case 'wb':
         case 'x':
         case 'x+':
             $this->cleardircache();
             $this->tmpfile = tempnam('/tmp', 'smb.up.');
             $this->need_flush = true;
     }
     $this->stream = fopen($this->tmpfile, $mode);
     return TRUE;
 }
Esempio n. 3
0
 public function stream_open($url, $mode, $options, $opened_path)
 {
     $url = smb::cleanUrl($url);
     $this->url = $url;
     $this->mode = $mode;
     $this->defer_stream_read;
     $this->parsed_url = $pu = smb::parse_url($url);
     if ($pu['type'] != 'path') {
         trigger_error('stream_open(): error in URL', E_USER_ERROR);
     }
     switch ($mode) {
         case 'r':
         case 'r+':
         case 'rb':
         case 'a':
         case 'a+':
             // REFERENCE STREAM BUT DO NOT OPEN IT UNTIL READING IS REALLY NECESSARY!
             /*
             $this->tmpfile = tempnam(SMB4PHP_SMBTMP, 'smb.down.');
             smb::execute ('get "'.$pu['path'].'" "'.$this->tmpfile.'"', $pu);
             $this->stream = fopen ($this->tmpfile, $mode);
             */
             $this->defer_stream_read = true;
             break;
         case 'w':
         case 'w+':
         case 'wb':
         case 'x':
         case 'x+':
             $this->cleardircache();
             $this->tmpfile = tempnam(SMB4PHP_SMBTMP, 'smb.up.');
             $this->stream = fopen($this->tmpfile, $mode);
             $this->need_flush = TRUE;
     }
     //$this->stream = fopen ($this->tmpfile, $mode);
     return TRUE;
 }