Method to write a string to the FTP server

@param   string  $remote  FTP path to file to write to
@param   string  $buffer  Contents to write to the FTP server

@return  boolean  True if successful

@since   1.0
5732
public function write($remote, $buffer)
	{
		// Determine file type
		$mode = $this->_findMode($remote);

		// If native FTP support is enabled let's use it...
		if (FTP_NATIVE)
		{
			// Turn passive mode on
			if (@ftp_pasv($this->conn, true) === false)
			{
				Log::add(__METHOD__ . ': Unable to use passive mode.', Log::WARNING, 'jerror');

				return false;
			}

			$tmp = fopen('buffer://tmp', 'br+');
			fwrite($tmp, $buffer);
			rewind($tmp);

			if (@ftp_fput($this->conn, $remote, $tmp, $mode) === false)
			{
				fclose($tmp);
				Log::add(__METHOD__ . 'Bad response.', Log::WARNING, 'jerror');

				return false;
			}

			fclose($tmp);

			return true;
		}

		// First we need to set the transfer mode
		$this->_mode($mode);

		// Start passive mode
		if (!$this->_passive())
		{
			Log::add(__METHOD__ . ': Unable to use passive mode.', Log::WARNING, 'jerror');

			return false;
		}

		// Send store command to the FTP server
		if (!$this->_putCmd('STOR ' . $remote, array(150, 125)))
		{
			Log::add(
				sprintf('%1$s: Bad response.  Server response: %2$s [Expected: 150 or 125].  Path sent: %3$s', __METHOD__, $this->response, $remote),
				Log::WARNING, 'jerror'
			);
			@ fclose($this->dataconn);

			return false;
		}

		// Write buffer to the data connection port
		do
		{
			if (($result = @ fwrite($this->dataconn, $buffer)) === false)
			{
				Log::add(__METHOD__ . ': Unable to write to data port socket.', Log::WARNING, 'jerror');

				return false;
			}

			$buffer = substr($buffer, $result);
		}

		while ($buffer != "");

		// Close the data connection port [Data transfer complete]
		fclose($this->dataconn);

		// Verify that the server recieved the transfer
		if (!$this->_verifyResponse(226))
		{
			Log::add(
				sprintf('%1$s: Transfer failed.  Server response: %2$s [Expected: 226].  Path sent: %3$s', __METHOD__, $this->response, $remote),
				Log::WARNING, 'jerror'
			);

			return false;
		}

		return true;
	}
1239487
public function delete($remote_path, $recursive = false)
    {
        $remote_path = $this->_getAbsoluteRemotePath($remote_path);
        if (true === @is_dir($remote_path)) {
            if (true === $recursive) {
                foreach ($this->ls($remote_path) as $file) {
                    if ('.' !== $file && '..' !== $file) {
                        $this->delete($remote_path.DIRECTORY_SEPARATOR.$file, $recursive);
                    }
                }
            }

            if (false === @rmdir($remote_path)) {
                return $this->_trigger_error(sprintf('Unable to delete directory %s', $remote_path));
            }
        } else {
            if (false === @unlink($remote_path)) {
                return $this->_trigger_error(sprintf('Unable to delete file %s', $remote_path));
            }
        }

        return true;
    }
50348
public function putFile($local, $remote)
    {
        return ftp_put($this->connection, $remote, $local, $this->getTransferenceEncoding($local));
    }
495684
public function size($remote_file)
    {
        $size = @ftp_size($this->connection, $remote_file);
        if ($size && $size != -1) {
            return $size;
        } else {
            throw new \Exception("Could not get remote file size: " . $path);
        }
    }
1251705
public function putFromString($remote_file, $content)
    {
        $handle = fopen('php://temp', 'w');

        fwrite($handle, $content);
        rewind($handle);

        if ($this->ftp->fput($remote_file, $handle, FTP_BINARY)) {
            return $this;
        }

        throw new FtpException('Unable to put the file "'.$remote_file.'"');
    }
1202536
public function getContent($remote_file, $mode = FTP_BINARY, $resumepos = 0)
    {
        $handle = fopen('php://temp', 'r+');

        if ($this->fget($handle, $remote_file, $mode, $resumepos)) {
            rewind($handle);
            return stream_get_contents($handle);
        }

        return null;
    }
303638
protected function scpSend($local_path, $remote_path, $mode=0644)
    {
        if(@ssh2_scpSend($connection, $remote_path, $remote_path, $mode)){
            throw new \Exception("Could send file with scp: ".$local_path.' to '.$remote_path);
        }
    }
629835
protected function _fwriteStream(&$fp, &$string) {
		$fwrite = 0;
		for($written = 0; $written < strlen($string); $written += $fwrite){
			$fwrite = @fwrite($fp, substr($string, $written));

			if($fwrite === false){
				return $written;
			}

			if(!$fwrite){ // 0 bytes written; error code  11:  Resource temporarily unavailable
				usleep(10000);
				continue;
			}
		}
		return $written;
	}
623027
public function put($local_file = null, $remote_file = null, $mode = FTP_ASCII)
    {
        if (\ftp_put($this->_stream, $remote_file, $local_file, $mode)) {
            return true;
        }

        $this->error = 'Failed to upload file "'.$local_file.'"';

        return false;
    }
1342219
public function write($string)
    {
        if (strlen($string) !== $bytesWritten = fwrite($this->getHandle(), $string)) {
            throw new RuntimeException(
                'Buffer could not be written to stream.'
            );
        }

        return $bytesWritten;
    }
674543
public function wget($httpFile, $remote)
    {
        if (! ini_get('allow_url_fopen')) {
            throw new \RuntimeException('allow_url_fopen must enabled');
        }
        if (! $fileData = file_get_contents($httpFile)) {
            throw new \RuntimeException('Can nat get file content');
        }
        $parseFile = $this->parseLastDirectory($remote);
        if (! file_put_contents($this->getWrapper("/$parseFile"), $fileData)) {
            throw new FileException('File not uploaded to ftp server');
        }
        return true;
    }
293798
public function write($data)
    {
        for ($written = 0, $fwrite = 0; $written < strlen($data); $written += $fwrite) {
            $fwrite = fwrite($this->socket, substr($data, $written));
            if ($fwrite === false || ($fwrite === 0 && feof($this->socket))) {
                // broken pipe!
                if ($fwrite === 0 && feof($this->socket)) {
                    $this->close();
                }

                return false;
            }
        }

        return $written;
    }
145184
function write($text,$format='r') {
		$fw=Base::instance();
		$fw->write(
			$this->file,
			date($format).
				(isset($_SERVER['REMOTE_ADDR'])?
					(' ['.$_SERVER['REMOTE_ADDR'].']'):'').' '.
			trim($text).PHP_EOL,
			TRUE
		);
	}
1086198
public function write($string)
    {
        $this->buffer .= $string;

        if (strlen($this->buffer) >= $this->hwm) {
            return false;
        }

        return strlen($string);
    }
784540
public function get($remote_file, $local_file, $mode = null)
    {
        $mode = $mode ? $mode : FTP_ASCII;
        if (!@ftp_get($this->connection, $local_file, $remote_file, $mode)) {
            throw new \Exception("Could not get remote file:" . $remote_file);
        }

        return true;
    }
486115
public static function write($file, $buffer)
    {
        @set_time_limit((int) ini_get('max_execution_time'));

        // If the destination directory doesn't exist we need to create it
        if (!is_dir(dirname($file))) {
            Folder::create(dirname($file));
        }

        $file = Path::clean($file);

        return is_int(file_put_contents($file, $buffer)) ? true : false;
    }
864609
static public function curlDownload($remote,$local) {
        $cp = curl_init($remote);
        $fp = fopen($local,"w");
        curl_setopt($cp, CURLOPT_FILE, $fp);
        curl_setopt($cp, CURLOPT_HEADER, 0);
        curl_exec($cp);
        curl_close($cp);
        fclose($fp);
    }