protected function _putFile($name, $contents)
 {
     $stream = $this->toStream($contents);
     $result = ftp_fput($this->getConnection(), $name, $stream, FTP_ASCII);
     fclose($stream);
     return $result;
 }
Exemple #2
0
 function iwp_mmb_direct_to_any_copy($source, $destination, $overwrite = false, $mode = false)
 {
     //FIX ME: directly call function in backup.class.php later
     global $wp_filesystem;
     if ($wp_filesystem->method == 'direct') {
         return $wp_filesystem->copy($source, $destination, $overwrite, $mode);
     } elseif ($wp_filesystem->method == 'ftpext' || $wp_filesystem->method == 'ftpsockets') {
         if (!$overwrite && $wp_filesystem->exists($destination)) {
             return false;
         }
         //put content
         $source_handle = fopen($source, 'r');
         if (!$source_handle) {
             return false;
         }
         $sample_content = fread($source_handle, 1024 * 1024 * 2);
         //1024 * 1024 * 2 => 2MB
         fseek($source_handle, 0);
         //Skip back to the start of the file being written to
         $type = $wp_filesystem->is_binary($sample_content) ? FTP_BINARY : FTP_ASCII;
         unset($sample_content);
         if ($wp_filesystem->method == 'ftpext') {
             $ret = @ftp_fput($wp_filesystem->link, $destination, $source_handle, $type);
         } elseif ($wp_filesystem->method == 'ftpsockets') {
             $wp_filesystem->ftp->SetType($type);
             $ret = $wp_filesystem->ftp->fput($destination, $source_handle);
         }
         fclose($source_handle);
         unlink($source);
         //to immediately save system space
         $wp_filesystem->chmod($destination, $mode);
         return $ret;
     }
 }
Exemple #3
0
function subida_script($ftp_server, $ftp_user, $ftp_pass)
{
    // set up basic connection
    $conn_id = ftp_connect($ftp_server);
    if (!$conn_id) {
        echo "<div class='alert alert-warning' style='width:300px;margin:auto'>Connection established</div>";
    }
    // login with username and password
    $login_result = ftp_login($conn_id, $ftp_user, $ftp_pass);
    if ($login_result) {
        echo "<div class='alert alert-success' style='width:300px;margin:auto'>Connection established</div>";
    }
    ftp_chdir($conn_id, 'public_html');
    ftp_mkdir($conn_id, 'search');
    ftp_chdir($conn_id, 'search');
    ftp_mkdir($conn_id, 'css');
    ftp_chdir($conn_id, 'css');
    echo ftp_pwd($conn_id);
    ftp_chdir($conn_id, '../../autotienda/search');
    echo ftp_pwd($conn_id);
    //Uploading files...
    //to be uploaded
    $file = "search/.htaccess";
    $fp = fopen($file, 'r');
    ftp_fput($conn_id, $file, $fp, FTP_ASCII);
    echo ftp_pwd($conn_id);
    // close the connection
    ftp_close($conn_id);
    fclose($fp);
}
 function stream_flush()
 {
     if (!isset($this->connect) || !isset($this->cacheWHandler)) {
         return;
     }
     rewind($this->cacheWHandler);
     ftp_fput($this->connect, $this->path, $this->cacheWHandler, FTP_BINARY, 0);
 }
Exemple #5
0
 public static function CreateFile($filename, $conn)
 {
     //Придумати щось інше
     $fp = fopen('for_test_ftp', "w");
     $response = ftp_fput($conn, $filename, $fp, FTP_ASCII);
     fclose($fp);
     unlink('for_test_ftp');
     return $response;
 }
Exemple #6
0
function ftpWriteFile($ftpConn, $filepath, $contents, $ftpMode)
{
    // Create temp handler, this type needed for extended char set
    $tempHandle = fopen('php://temp', 'r+');
    // Write contents to handle and rewind head
    fwrite($tempHandle, $contents);
    rewind($tempHandle);
    // Write our content and return true/false
    return ftp_fput($ftpConn, $filepath, $tempHandle, $ftpMode, 0);
}
Exemple #7
0
 public function fput($remote, $handle, $mode = FTP_BINARY)
 {
     if ($this->_ftpStream) {
         if (!ftp_fput($this->_ftpStream, $remote, $handle, $mode)) {
             echo "Error in fput writing to {$remote}";
             return false;
         }
         return true;
     }
     return false;
 }
 public function putcontent($filename, $content)
 {
     if (!($temp = $this->gettempfilehandle())) {
         return false;
     }
     fseek($temp, 0);
     fwrite($temp, $content);
     ftruncate($temp, strlen($content));
     fseek($temp, 0);
     $result = @ftp_fput($this->handle, $filename, $temp, FTP_BINARY);
     return $result;
 }
Exemple #9
0
 /**
  * {@InheritDoc}
  */
 public function write($key, $content)
 {
     $path = $this->computePath($key);
     $directory = dirname($path);
     $this->ensureDirectoryExists($directory, true);
     $temp = fopen('php://temp', 'r+');
     $size = fwrite($temp, $content);
     rewind($temp);
     if (!ftp_fput($this->getConnection(), $path, $temp, FTP_ASCII)) {
         throw new \RuntimeException(sprintf('Could not write the \'%s\' file.', $key));
     }
     fclose($temp);
     return $size;
 }
Exemple #10
0
 /**
  * Enregistre le fichier sur un serveur FTP
  *
  * @param resource $ftp_stream -> La ressource de connexion FTP
  * @param string   $path       -> Le chemin complet du dossier de destination
  * @param string   $filename   -> Le nom du fichier
  * @return true si réussi, sinon false
  */
 public function saveFTP($ftp_stream, $path, $filename)
 {
     // Ouverture du flux "input" de PHP et création d'un fichier temp
     $input = fopen("php://input", "r");
     $temp = tmpfile();
     $realSize = stream_copy_to_stream($input, $temp);
     fclose($input);
     if ($realSize != $this->getSize()) {
         return false;
     }
     // Enregistre le fichier sur le FTP
     fseek($temp, 0, SEEK_SET);
     return ftp_fput($ftp_stream, $path . $filename, $temp, FTP_BINARY);
 }
Exemple #11
0
 /**
  * {@inheritDoc}
  */
 public function write($key, $content)
 {
     $path = $this->computePath($key);
     $directory = dirname($path);
     $this->ensureDirectoryExists($directory, true);
     $temp = fopen('php://temp', 'r+');
     $size = fwrite($temp, $content);
     rewind($temp);
     if (!ftp_fput($this->getConnection(), $path, $temp, $this->mode)) {
         fclose($temp);
         return false;
     }
     fclose($temp);
     return $size;
 }
Exemple #12
0
 public function up($source, $dest_file, $mimetype)
 {
     if (!$this->connect_id) {
         return false;
     }
     $mode = preg_match('/text/i', $mimetype) || preg_match('/html/i', $mimetype) ? FTP_ASCII : FTP_BINARY;
     if (is_resource($source)) {
         $res = ftp_fput($this->connect_id, $dest_file, $source, $mode);
     } else {
         $res = ftp_put($this->connect_id, $dest_file, $source, $mode);
     }
     if ($res) {
         ftp_site($this->connect_id, 'CHMOD 0644 ' . $dest_file);
     }
     return $res;
 }
Exemple #13
0
 /**
  * {@inheritdoc}
  */
 public function write($key, $content)
 {
     $this->ensureDirectoryExists($this->directory, $this->create);
     $path = $this->computePath($key);
     $directory = str_replace('\\', '/', \Gaufrette\Util\Path::dirname($path));
     $this->ensureDirectoryExists($directory, true);
     $temp = fopen('php://temp', 'r+');
     $size = fwrite($temp, $content);
     rewind($temp);
     if (!ftp_fput($this->getConnection(), $path, $temp, $this->mode)) {
         fclose($temp);
         return false;
     }
     fclose($temp);
     return $size;
 }
 /**
  * @Route("/backup", name="create_backup")
  * @Method("GET")
  * @Template()
  */
 public function createAction()
 {
     //echo PHP_OS;
     //include_once "conexion/def.php";
     set_time_limit(6000);
     date_default_timezone_set("America/El_Salvador");
     $backupFile = "laplusbelle_" . date("d-m-Y_H-i-s") . ".sql";
     $path = $this->container->getParameter('plusbelle.backup');
     $kernel = $this->get('kernel');
     //$path = $kernel->locateResource('@DGPlusbelleBundle/backup/'.$backupFile);
     $path = $this->get('kernel')->locateResource("@DGPlusbelleBundle/Resources/backup/");
     //var_dump($path);
     //$pathdirname($this->container->getParameter('kernel.root_dir')) . '/web/bundles/mybundle/myfiles'
     //    if(strpos(strtolower($path), 'win') !== false){
     //        $path=str_replace("/","\\",$path);
     //    }
     //var_dump($path);
     try {
         /////Hay que dar permisos al usuario de la base de datos, LOCK TABLES y SHOW DATABASES
         exec("mysqldump -h localhost -uadmin -p919293marvin marvinvi_demo_plusbella -R> " . $path . $backupFile);
     } catch (Exception $e) {
         echo $e->getMessage();
     }
     //die();
     // open some file for reading
     $file = 'backup/' . $backupFile;
     $file1 = $path . $backupFile;
     $fp = fopen($file1, 'r');
     // set up basic connection
     $conn_id = ftp_connect("digitalitygarage.com");
     $ftp_user_name = "*****@*****.**";
     $ftp_user_pass = "******";
     // login with username and password
     $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
     // try to upload $file
     if (ftp_fput($conn_id, $file, $fp, FTP_ASCII)) {
         echo "Successfully uploaded {$file}\n";
     } else {
         echo "There was a problem while uploading {$file}\n";
     }
     // close the connection and the file handler
     ftp_close($conn_id);
     fclose($fp);
     die;
     //    return $this->redirect($this->generateUrl('admin_backup'));
     return $this->redirect($this->generateUrl('admin_backup', array('estado' => '0')));
 }
 /**
  * Execute upload action and return URL.
  *
  * @return string|false
  *
  * @throws Exception If have an error occurred
  */
 protected function doUpload()
 {
     $level = error_reporting(E_ALL & ~E_WARNING);
     $this->getStream();
     $subfolder = date('Y/m/d');
     $this->preparePath($subfolder);
     $fpfile = fopen($this->file, 'r');
     $filename = $this->getRemoteFileName($this->file);
     $result = ftp_fput($this->stream, $filename, $fpfile, FTP_BINARY);
     fclose($fpfile);
     if (!$result) {
         $this->throwException('Cannot upload to this host "%s:%s", path: "%s"', $this->host, $this->port, $path);
     }
     $link = $this->getHostLink() . '/' . $subfolder . '/' . $filename;
     error_reporting($level);
     return $link;
 }
Exemple #16
0
 function save($path = '', $url, $id)
 {
     $system =& $GLOBALS['system'];
     $fp = fopen(BASE_DIR . $path, 'rb');
     $id = $path;
     $url = "http://" . __FTP_SERVER__ . "/" . $path;
     $ftp_path = __FTP_DIR__ . "/" . $path;
     $file = $ftp_path;
     // connect to the server
     $conn_id = ftp_connect(__FTP_SERVER__);
     $login_result = ftp_login($conn_id, __FTP_UNAME__, __FTP_PASSWD__);
     $d = split("/", $ftp_path);
     $ftp_path = "";
     if (substr(__FTP_DIR__, 0, 1) == "/") {
         $i = 1;
     } else {
         $i = 0;
     }
     for ($i; $i < count($d) - 1; $i++) {
         $ftp_path .= "/" . $d[$i];
         if (!@ftp_chdir($conn_id, $ftp_path)) {
             @ftp_chdir($conn_id, "/");
             if (!@ftp_mkdir($conn_id, $ftp_path)) {
                 return false;
             }
         }
     }
     // try to upload the file
     ftp_fput($conn_id, $file, $fp, FTP_BINARY);
     $o = $system->loadModel('goods/gimage');
     foreach ($o->defaultImages as $tag) {
         $ext = $o->getImageExt(BASE_DIR . $path);
         $otherimage = substr(BASE_DIR . $path, 0, strlen(BASE_DIR . $path) - strlen($ext)) . "_" . $tag . $ext;
         if (file_exists($otherimage)) {
             $fp = fopen($otherimage, 'rb');
             ftp_fput($conn_id, $ftp_path . "/" . basename($otherimage), $fp, FTP_BINARY);
             fclose($fp);
             @unlink($otherimage);
         }
     }
     @unlink(BASE_DIR . $path);
     // close the connection and the file handler
     ftp_close($conn_id);
     fclose($fp);
     return true;
 }
 function put_contents($file, $contents)
 {
     $result = false;
     if ($ftp = AkFtpClient::connect()) {
         $file = str_replace('\\', '/', $file);
         $tmpfname = tempnam('/tmp', 'tmp');
         $temp = fopen($tmpfname, 'a+');
         fwrite($temp, $contents);
         fclose($temp);
         $temp = fopen($tmpfname, 'rb');
         ftp_pasv($ftp, true);
         $result = ftp_fput($ftp, $file, $temp, FTP_ASCII);
         fclose($temp);
         unlink($tmpfname);
     }
     return $result;
 }
Exemple #18
0
function SaveComment($id, $comment)
{
    $temp = fopen('php://temp', 'r+');
    $ftp = GetFtpHandle();
    if ($ftp !== false) {
        ftp_fget($ftp, $temp, $id . ".comment", FTP_BINARY, 0);
        fwrite($temp, $comment . "\r\n");
        rewind($temp);
        if (ftp_fput($ftp, $id . ".comment", $temp, FTP_BINARY)) {
            fclose($temp);
            ftp_close($ftp);
            return true;
        }
        ftp_close($ftp);
    }
    fclose($temp);
    return false;
}
Exemple #19
0
function updateGAzieCart($server,$user,$pass,$data,$filename)
{
    gaz_set_time_limit (30); // azzero il tempo altrimenti vado in fatal_error
    $fn_exp = explode("/", $filename);
    $filename=array_pop($fn_exp);
    // set up a connection or die
    $conn_id = @ftp_connect($server);
    if (!$conn_id){
        return '0+'; // torno l'errore di server
    }
    // faccio il login
    if (!@ftp_login($conn_id, $user, $pass)) {
            ftp_close($conn_id);
            return '1+'; // torno l'errore di login
    }
    //turn passive mode on
    ftp_pasv($conn_id, true);
    foreach( $fn_exp as $dir){
        // faccio i cambi di direttorio
        if (!@ftp_chdir($conn_id, $dir)) {
            ftp_close($conn_id);
            return '2+'; // torno l'errore di direttorio inesistente
        }
    }
    // scrivo il file temporaneamente sul filesystem del server
    // quindi questo file deve poter essere scritto da Apache, quindi i permessi devono essere giusti
    $fp=fopen('gaziecart.tmp','w+');
    fwrite($fp,$data);
    fclose($fp);
    // elimino il file sul sito per poterlo riscrivere
    $fp=fopen('gaziecart.tmp','r');
    @ftp_delete($conn_id, $filename);
    // faccio l'upload del nuovo file
    if (!@ftp_fput($conn_id, $filename,$fp, FTP_BINARY)) {
            fclose($fp);
            ftp_close($conn_id);
            return '3+'; // torno l'errore di file
    }
    fclose($fp);
    // close the connection
    ftp_close($conn_id);
    return false;
}
Exemple #20
0
 /**
  * Update the NSN ftp server files states.
  * @param type $filesToUpdate An array of updated files states.
  * @throws Exception 
  */
 public function updateFilesState($filesToUpdate)
 {
     $processedPath = $this->_path . DIRECTORY_SEPARATOR . $this->outgoingFilename;
     $outgoingFile = $this->getRemoteFile($processedPath);
     //do the updating : seek to the file record and update its timestamp.
     foreach ($filesToUpdate as $id => $value) {
         if ($id > 0 && $value['state'] == static::FILE_STATE_FULL && isset($value['updated']) && $value['updated'] == true) {
             fseek($outgoingFile, $id * static::OUTGOING_RECORD_SIZE);
             $strTime = date('siHdmy', $value['time']) . substr(date('Y', $value['time']), 0, 2);
             fwrite($outgoingFile, pack('H*', $strTime), static::OUTGOING_RECORD_SIZE);
         }
     }
     fflush($outgoingFile);
     fseek($outgoingFile, 0);
     //upload the updated file to the server.
     if (!ftp_fput($this->_ftp->getConnection(), $processedPath, $outgoingFile, FTP_BINARY)) {
         throw new Exception('couldnt upload ' . static::OUTGOING_FILE_NAME . ' File from NSN server');
     }
     fclose($outgoingFile);
 }
Exemple #21
0
 function put_contents($file, $contents)
 {
     $result = false;
     if ($ftp = AkFtp::connect()) {
         $file = str_replace('\\', '/', $file);
         $path = dirname($file);
         if (!AkFtp::is_dir($path)) {
             AkFtp::make_dir($path);
         }
         $tmpfname = tempnam('/tmp', 'tmp');
         $temp = fopen($tmpfname, 'a+');
         fwrite($temp, $contents);
         fclose($temp);
         $temp = fopen($tmpfname, 'rb');
         $result = ftp_fput($ftp, $file, $temp, FTP_BINARY);
         fclose($temp);
         unlink($tmpfname);
     }
     return $result;
 }
Exemple #22
0
function copyFileViaFtp($sourcePath, $destinationPath, $connectionId)
{
    $errorMessage = '';
    $sourcePath = str_replace(" ", "-", $sourcePath);
    $destinationPath = sanitiseFtpPath($destinationPath);
    if (@(!ftp_mkdir($connectionId, $destinationPath))) {
        $errorMessage .= "&error-ftp-unable-to-create-directory; " . $destinationPath . "\n";
    }
    @ftp_site($connectionId, 'CHMOD 0777 ' . $destinationPath);
    // non-Unix-based servers may respond with "Command not implemented for that parameter" as they don't support chmod, so don't display any errors of this command.
    ftp_chdir($connectionId, $destinationPath);
    //print $sourcePath.' to '.$destinationPath."<br />";
    if (is_dir($sourcePath)) {
        chdir($sourcePath);
        $handle = opendir('.');
        while (($file = readdir($handle)) !== false) {
            if ($file != "." && $file != "..") {
                if (is_dir($file)) {
                    $errorMessage .= copyFileViaFtp($sourcePath . DIRECTORY_SEPARATOR . $file, $file, $connectionId);
                    chdir($sourcePath);
                    if (!ftp_cdup($connectionId)) {
                        $errorMessage .= '&error-unable-ftp-cd-up;';
                    }
                } else {
                    if (substr($file, strlen($file) - 4, 4) != '.zip') {
                        $fp = fopen($file, 'r');
                        if (!ftp_fput($connectionId, sanitiseFtpPath($file), $fp, FTP_BINARY)) {
                            $errorMessage .= '&error-unable-ftp-fput;';
                        }
                        @ftp_site($connectionId, 'CHMOD 0755 ' . sanitiseFtpPath($file));
                        fclose($fp);
                    }
                }
            }
        }
        closedir($handle);
    }
    return $errorMessage;
}
/**
* 100157636
100158071
100157638
100158073
100150757
*
*
*
*/
if ($fh1 = fopen('/home/sdc/bin/export/' . $file, 'r')) {
    $conn_id = ftp_connect(FTP_SERVER);
    $login_result = ftp_login($conn_id, FTP_USER, FTP_PASSWORD);
    ftp_pasv($conn_id, true);
    ftp_chdir($conn_id, FTP_FOLDER);
    if (ftp_fput($conn_id, $file, $fh1, FTP_ASCII)) {
        //echo "$file wurde erfolgreich hochgeladen\n";
    } else {
        echo "{$file} konnte nicht hochgeladen werden\n";
    }
    // Verbindung und Verbindungshandler schlie�en
    ftp_close($conn_id);
    fclose($fh1);
} else {
    print 'Datei konnte nicht geoeffnet werden ';
    exit;
}
function getExportContent()
{
    $fake_suppliernumber = array('No Name', '000', '0000', 'Diverse', '', ' ');
    $ordernumber = 0;
Exemple #24
0
 function ftp_fput($remote_file, $sourcefp, $mode = FTP_BINARY)
 {
     $remote_file = discuz_ftp::clear($remote_file);
     $mode = intval($mode);
     return @ftp_fput($this->connectid, $remote_file, $sourcefp, $mode);
 }
 /**
  * Write a string to a file
  *
  * @param  string  $path     file path
  * @param  string  $content  new file content
  * @return bool
  * @author Dmitry (dio) Levashov
  **/
 protected function _filePutContents($path, $content)
 {
     $res = false;
     if ($this->tmp) {
         $local = $this->getTempFile();
         if (@file_put_contents($local, $content, LOCK_EX) !== false && ($fp = @fopen($local, 'rb'))) {
             clearstatcache();
             $res = ftp_fput($this->connect, $path, $fp, $this->ftpMode($path));
             @fclose($fp);
         }
         file_exists($local) && @unlink($local);
     }
     return $res;
 }
Exemple #26
0
 /**
  * @inheritdoc
  */
 public function writeStream($path, $resource, Config $config)
 {
     $this->ensureDirectory(Util::dirname($path));
     if (!ftp_fput($this->getConnection(), $path, $resource, $this->transferMode)) {
         return false;
     }
     if ($visibility = $config->get('visibility')) {
         $this->setVisibility($path, $visibility);
     }
     return compact('path', 'visibility');
 }
Exemple #27
0
 /**
  * Method to write a string to the FTP server
  *
  * @access public
  * @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
  */
 function write($remote, $buffer)
 {
     // Determine file type
     $mode = $this->_findMode($remote);
     // If native FTP support is enabled lets use it...
     if (FTP_NATIVE) {
         // turn passive mode on
         if (@ftp_pasv($this->_conn, true) === false) {
             JError::raiseWarning('36', 'JFTP::write: Unable to use passive mode');
             return false;
         }
         $tmp = fopen('buffer://tmp', 'br+');
         fwrite($tmp, $buffer);
         rewind($tmp);
         if (@ftp_fput($this->_conn, $remote, $tmp, $mode) === false) {
             fclose($tmp);
             JError::raiseWarning('35', 'JFTP::write: Bad response');
             return false;
         }
         fclose($tmp);
         return true;
     }
     // First we need to set the transfer mode
     $this->_mode($mode);
     // Start passive mode
     if (!$this->_passive()) {
         JError::raiseWarning('36', 'JFTP::write: Unable to use passive mode');
         return false;
     }
     // Send store command to the FTP server
     if (!$this->_putCmd('STOR ' . $remote, array(150, 125))) {
         JError::raiseWarning('35', 'JFTP::write: Bad response', 'Server response: ' . $this->_response . ' [Expected: 150 or 125] Path sent: ' . $remote);
         @fclose($this->_dataconn);
         return false;
     }
     // Write buffer to the data connection port
     do {
         if (($result = @fwrite($this->_dataconn, $buffer)) === false) {
             JError::raiseWarning('37', 'JFTP::write: Unable to write to data port socket');
             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)) {
         JError::raiseWarning('37', 'JFTP::write: Transfer Failed', 'Server response: ' . $this->_response . ' [Expected: 226] Path sent: ' . $remote);
         return false;
     }
     return true;
 }
 /**
  * @param string $file
  * @param string $contents
  * @param bool|int $mode
  * @return bool
  */
 public function put_contents($file, $contents, $mode = false)
 {
     $tempfile = wp_tempnam($file);
     $temp = fopen($tempfile, 'wb+');
     if (!$temp) {
         return false;
     }
     mbstring_binary_safe_encoding();
     $data_length = strlen($contents);
     $bytes_written = fwrite($temp, $contents);
     reset_mbstring_encoding();
     if ($data_length !== $bytes_written) {
         fclose($temp);
         unlink($tempfile);
         return false;
     }
     fseek($temp, 0);
     // Skip back to the start of the file being written to
     $ret = @ftp_fput($this->link, $file, $temp, FTP_BINARY);
     fclose($temp);
     unlink($tempfile);
     $this->chmod($file, $mode);
     return $ret;
 }
Exemple #29
0
 /**
  * Create a lockfile using the appropriate functionality, depending
  * on the selected file operation.
  * @param String $lockfile
  */
 public static function createLockfile($lockfile)
 {
     switch (self::$fileOper) {
         case 'ftp':
             $stream = fopen('data://text/plain,' . time(), 'r');
             if (!@ftp_fput(self::$_ftpStream, self::ftpStripChroot($lockfile), $stream, FTP_BINARY)) {
                 throw new Exception("Unable to create lockfile {$lockfile}", self::ERR_FTPOPER);
             }
             fclose($stream);
             break;
         case 'php':
         default:
             file_put_contents($lockfile, time());
     }
 }
Exemple #30
0
 /**
  * Write a file from string, file or stream
  *
  * @param string $filename
  * @param string|resource $src filename, string data or source stream
  * @return int|boolean
  */
 public function write($filename, $src, $mode = null)
 {
     if (is_string($src) && is_readable($src)) {
         return @ftp_put($this->_conn, $filename, $src, $this->_config['file_mode']);
     } else {
         if (is_string($src)) {
             $stream = tmpfile();
             fputs($stream, $src);
             fseek($stream, 0);
         } elseif (is_resource($src)) {
             $stream = $src;
         } else {
             $this->_error = self::ERROR_INVALID_SOURCE;
             return false;
         }
         $result = ftp_fput($this->_conn, $filename, $stream, $this->_config['file_mode']);
         if (is_string($src)) {
             fclose($stream);
         }
         return $result;
     }
 }