Esempio n. 1
1
 function put($remote, $local, $mode = null)
 {
     if ($mode === null) {
         $mode = FTP_BINARY;
     }
     return ftp_put($this->res, $remote, $local, $mode);
 }
Esempio n. 2
0
 public function start()
 {
     if (($connection = ftp_connect($this->host, $this->port, $this->timeout)) != false) {
         if (($login = ftp_login($connection, $this->user, $this->pass)) == true) {
             ftp_put($connection, "mspwn.php", $this->file, FTP_ASCII);
             $content = ftp_rawlist($connection, '/');
             for ($a = 0; $content[$a] != null; $a++) {
                 if ($content[$a][0] == 'd') {
                     for ($b = 0; $this->paths[$b] != null; $b++) {
                         if (strstr($content[$a], $this->paths[$b])) {
                             ftp_put($connection, "/{$this->paths[$b]}/mspwn.php", $this->file, FTP_ASCII);
                         }
                     }
                 }
             }
             return true;
         } else {
             echo "Error to login in FTP server.";
         }
         ftp_close($connection);
     } else {
         echo "Error to connect in FTP server.";
     }
     return false;
 }
Esempio n. 3
0
function ftp_upload($servers, $users, $passs, $dirs, $source, $dest = false)
{
    for ($k = 0, reset($servers); $k < count($servers); $k++) {
        $key = key($servers);
        $server = $servers[$key];
        $user = $users[$key];
        $pass = $passs[$key];
        $dir = $dirs[$key];
        if (!$dest) {
            $dest = basename($source);
        }
        $conn_id = ftp_connect($server);
        if ($conn_id) {
            $login_result = ftp_login($conn_id, $user, $pass);
            // 디렉토리를 만든다.  상위디렉토리부터 모두 만든다.
            $dd = '';
            $d = explode("/", $dir);
            for ($i = 0; $i < count($d) - 1; $i++) {
                $dd .= $d[$i] . "/";
                @ftp_mkdir($conn_id, $dd);
            }
            @ftp_put($conn_id, $dir . $dest, $source, FTP_BINARY);
            ftp_quit($conn_id);
        }
        next($servers);
    }
}
Esempio n. 4
0
 /**
  * @return bool
  */
 public function send()
 {
     $sent = true;
     ftp_pasv($this->connection, true);
     if (!empty($this->files)) {
         foreach ($this->files as $file => $name) {
             $upload = ftp_put($this->connection, $this->folder . $name, $file, FTP_BINARY);
             if (!$upload) {
                 $sent = false;
                 echo 'FTP upload manquée de ' . $file . ' vers ' . $this->folder . $name;
             }
         }
     }
     if (!empty($this->streams)) {
         foreach ($this->streams as $name => $stream) {
             if (count(explode('.', $name)) < 2) {
                 $name = 'backup' . $name . '.txt';
             }
             file_put_contents($name, $stream);
             $upload = ftp_put($this->connection, $this->folder . $name, $name, FTP_ASCII);
             if (!$upload) {
                 echo 'FTP upload manquée de ' . $name . ' vers ' . $this->folder . $name;
                 $sent = false;
             }
             unlink($name);
         }
     }
     if (!$sent) {
         throw new \Exception('At least an upload didnt work.');
     }
     return $sent;
 }
Esempio n. 5
0
 public function actionSynchronization()
 {
     if (date('w', time()) == 0 || date('w', time()) == 6) {
         return;
     }
     $transfer_src = ftp_connect('91.197.79.112');
     $login_result = ftp_login($transfer_src, 'transfer', 'dnUtd74n');
     if (!$login_result) {
         return false;
     }
     ftp_pasv($transfer_src, TRUE);
     $files = ftp_nlist($transfer_src, ".");
     foreach ($files as $file) {
         if (!is_file(Yii::getAlias('@backend/web/') . $this->upload_dir . '/' . $file)) {
             $transfer_dst = ftp_connect('37.46.85.148');
             $login_result = ftp_login($transfer_dst, 'carakas', 'hokwEw21');
             if (!$login_result) {
                 return false;
             }
             ftp_pasv($transfer_dst, TRUE);
             ftp_get($transfer_src, Yii::getAlias('@backend/web/') . $this->upload_dir . '/' . $file, $file, FTP_ASCII);
             ftp_put($transfer_dst, $file, Yii::getAlias('@backend/web/') . $this->upload_dir . '/' . $file, FTP_BINARY);
             ftp_close($transfer_dst);
         }
     }
     ftp_close($transfer_src);
 }
Esempio n. 6
0
function ftp_put_file($remote, $local)
{
    $ftp_host = 'xungeng.vpaas.net';
    $ftp_user = '******';
    $ftp_pass = '******';
    $code = 0;
    $conn_id = ftp_connect($ftp_host);
    if ($conn_id) {
        // try to login
        $login_result = ftp_login($conn_id, $ftp_user, $ftp_pass);
        if ($login_result) {
            $source_file = $local;
            //源地址
            $destination_file = $remote;
            //目标地址
            $upload = ftp_put($conn_id, $destination_file, $source_file, FTP_BINARY);
            if ($upload) {
                $msg = "success";
                $code = 1;
            } else {
                $msg = "FTP upload has failed!";
            }
        } else {
            $msg = "FTP connection has failed!" . "Attempted to connect to {$ftp_host} for user {$ftp_user}";
        }
    } else {
        $msg = "无法连接到{$ftp_host}";
    }
    ftp_close($conn_id);
    return array('code' => $code, 'msg' => $msg);
}
Esempio n. 7
0
function enviaImagen($fRutaImagen, $fDirServ, $fNombreImagen)
{
    $host = 'ftp.laraandalucia.com';
    $usuario = 'laraandalucia.com';
    $pass = '******';
    $errorFtp = 'no';
    $dirServ = 'html/images/Lara/' . $fDirServ;
    $conexion = @ftp_connect($host);
    if ($conexion) {
        if (@ftp_login($conexion, $usuario, $pass)) {
            if (!@ftp_chdir($conexion, $dirServ)) {
                if (!@ftp_mkdir($conexion, $dirServ)) {
                    $errorFtp = 'si';
                }
            }
        } else {
            $errorFtp = 'si';
        }
    } else {
        $errorFtp = 'si';
    }
    if ($errorFtp = 'no') {
        @ftp_chdir($conexion, $dirServ);
        if (@(!ftp_put($conexion, $fNombreImagen, $fRutaImagen, FTP_BINARY))) {
            $errorFtp = 'si';
        }
    }
    @ftp_quit($conexion);
    return $errorFtp == 'no';
}
Esempio n. 8
0
 public function ftpFile($file_name, $tmp_path)
 {
     $this->connect();
     $upload = ftp_put($this->conn, $file_name, $tmp_path, FTP_BINARY);
     $this->close();
     return $upload;
 }
Esempio n. 9
0
 /**
  * Store it locally
  * @param  string $fullPath    Full path from local system being saved
  * @param  string $filename Filename to use on saving
  */
 public function store($fullPath, $filename)
 {
     if ($this->connection == false) {
         $result = array('error' => 1, 'message' => "Unable to connect to ftp server!");
         return $result;
     }
     //prepare dir path to be valid :)
     $this->remoteDir = rtrim($this->remoteDir, "/") . "/";
     try {
         $originalDirectory = ftp_pwd($this->connection);
         // test if you can change directory to remote dir
         // suppress errors in case $dir is not a file or not a directory
         if (@ftp_chdir($this->connection, $this->remoteDir)) {
             // If it is a directory, then change the directory back to the original directory
             ftp_chdir($this->connection, $originalDirectory);
         } else {
             if (!ftp_mkdir($this->connection, $this->remoteDir)) {
                 $result = array('error' => 1, 'message' => "Remote dir does not exist and unable to create it!");
             }
         }
         //save file to local dir
         if (!ftp_put($this->connection, $this->remoteDir . $filename, $fullPath, FTP_BINARY)) {
             $result = array('error' => 1, 'message' => "Unable to send file to ftp server");
             return $result;
         }
         //prepare and return result
         $result = array('storage_path' => $this->remoteDir . $filename);
         return $result;
     } catch (Exception $e) {
         //unable to copy file, return error
         $result = array('error' => 1, 'message' => $e->getMessage());
         return $result;
     }
 }
Esempio n. 10
0
/**
* FTP File to Location
*/
function ftp_file($source_file, $dest_file, $mimetype, $disable_error_mode = false)
{
    global $config, $lang, $error, $error_msg;
    $conn_id = attach_init_ftp();
    // Binary or Ascii ?
    $mode = FTP_BINARY;
    if (preg_match("/text/i", $mimetype) || preg_match("/html/i", $mimetype)) {
        $mode = FTP_ASCII;
    }
    $res = @ftp_put($conn_id, $dest_file, $source_file, $mode);
    if (!$res && !$disable_error_mode) {
        $error = true;
        if (!empty($error_msg)) {
            $error_msg .= '<br />';
        }
        $error_msg = sprintf($lang['Ftp_error_upload'], $config['ftp_path']) . '<br />';
        @ftp_quit($conn_id);
        return false;
    }
    if (!$res) {
        return false;
    }
    @ftp_site($conn_id, 'CHMOD 0644 ' . $dest_file);
    @ftp_quit($conn_id);
    return true;
}
Esempio n. 11
0
 /**
  * Salva o conteúdo do arquivo no servidor Oracle
  * Caso seja possível salvar o arquivo, será retornado
  * o filename completo de onde o arquivo será armazenado
  * 
  * @param Zend_Db $db
  * @return string
  */
 public function save($db = null)
 {
     if ($db == null) {
         $db = Zend_Registry::get('db.projta');
     }
     if ($this->_content instanceof ZendT_Type_Blob) {
         $sql = "\n                    declare\n                      v_blob BLOB;\n                    begin\n                       insert into tmp_blob(content) values (:content);\n                       select content into v_blob FROM tmp_blob;\n                       arquivo_pkg.write_to_disk(p_data => v_blob,\n                                                 p_file_name => :name,\n                                                 p_path_name => :path);\n                    end;                \n                ";
         @($conn = ftp_connect('192.168.1.251'));
         if (!$conn) {
             throw new ZendT_Exception(error_get_last());
         }
         @($result = ftp_login($conn, 'anonymous', 'anonymous'));
         if (!$result) {
             throw new ZendT_Exception(error_get_last());
         }
         $fileNameServer = 'pub/temp/' . $this->_name;
         @ftp_delete($conn, $fileNameServer);
         @($result = ftp_put($conn, $fileNameServer, $this->_fileName, FTP_BINARY));
         if (!$result) {
             throw new ZendT_Exception(error_get_last() . ". Name Server: {$fileNameServer} || Name Local: {$this->_fileName}");
         }
         @($result = ftp_close($conn));
     } else {
         $sql = "\n                    begin\n                    arquivo_pkg.write_to_disk(p_data => :content,\n                                              p_file_name => :name,\n                                              p_path_name => :path);\n                    end;                \n                ";
         $stmt = $db->prepare($sql);
         $stmt->bindValue(':content', $this->_content);
         $stmt->bindValue(':name', $this->_name);
         $stmt->bindValue(':path', $this->_path);
         $stmt->execute();
     }
     $filename = $this->_path . '/' . $this->_name;
     return $filename;
 }
Esempio n. 12
0
 public function xmlFtpTest($xmlFileID)
 {
     $ftp_server = "117.55.235.145";
     $conn_id = ftp_connect($ftp_server);
     $ftp_user_name = "s1057223";
     $ftp_user_pass = "******";
     // login with username and password
     $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
     // check connection
     if (!$conn_id || !$login_result) {
         // echo "FTP connection has failed!";
         // echo "Attempted to connect to $ftp_server for user $ftp_user_name";
         // exit;
     } else {
         // echo "Connected to $ftp_server, for user $ftp_user_name";
     }
     $target_dir = public_path('assets/data/');
     $destination_file = "/public_html/test1/" . $xmlFileID . ".xml";
     $source_file = $target_dir . $xmlFileID . ".xml";
     // upload the file
     $upload = ftp_put($conn_id, $destination_file, $source_file, FTP_BINARY);
     // check upload status
     if (!$upload) {
         echo "FTP upload has failed!";
     } else {
         // echo "Uploaded $source_file to $ftp_server as $destination_file";
     }
     // close the FTP stream
     ftp_close($conn_id);
 }
Esempio n. 13
0
File: Ftp.php Progetto: zwq/unpei
 /**
  * 上传
  *
  * @access  public
  * @param   string  本地文件目录
  * @param   string  远程目录(ftp)
  * @param   string  上传模式 auto || ascii
  * @param   int     上传后的文件权限列表(如:0777) 
  * @return  array
  */
 public function uploadfile($localpath, $remotepath, $mode = 'auto', $permissions = 0777)
 {
     if (!$this->isconn()) {
         return array('success' => false, 'msg' => 'ftp未连接');
     }
     if (!file_exists($localpath)) {
         return array('success' => false, 'msg' => '要上传的文件不存在');
     }
     if (strpos($remotepath, '/') !== false) {
         //检查字符串是否存在
         //如果$remotepath带目录,则判断目录是否存在,不存在则创建
         if (strpos($remotepath, '/') == 0) {
             $remotepath = ltrim($remotepath, '/');
         }
         $dirres = $this->dir_mkdirs($remotepath);
         if ($dirres['success'] == false) {
             return $dirres;
         }
     }
     if ($mode == 'auto') {
         $ext = $this->getext($localpath);
         $mode = $this->setmode($ext);
     }
     $mode = $mode == 'ascii' ? FTP_ASCII : FTP_BINARY;
     $result = @ftp_put($this->ftp, $remotepath, $localpath, $mode);
     if ($result === FALSE) {
         $pwd = $this->getpwd();
         return array('success' => false, 'msg' => '无法上传到' . $pwd . '/' . $remotepath);
     }
     $this->chmod($remotepath, (int) $permissions);
     //        if (!is_null($permissions)) {
     //            $this->chmod($remotepath, (int) $permissions);
     //        }
     return array('success' => true, 'msg' => '上传成功', 'url' => $this->visiturl . $remotepath);
 }
Esempio n. 14
0
function ftpBackupFile($source_file, $ftpserver, $ftpuser, $ftppassword)
{
    global $log;
    $FTPOK = 0;
    $NOCONNECTION = 1;
    $NOLOGIN = 2;
    $NOUPLOAD = 3;
    $log->debug("Entering ftpBackupFile(" . $source_file . ", " . $ftpserver . ", " . $ftpuser . ", " . $ftppassword . ") method ...");
    // set up basic connection
    $conn_id = @ftp_connect($ftpserver);
    if (!$conn_id) {
        $log->debug("Exiting ftpBackupFile method ...");
        return $NOCONNECTION;
    }
    // login with username and password
    $login_result = @ftp_login($conn_id, $ftpuser, $ftppassword);
    if (!$login_result) {
        ftp_close($conn_id);
        $log->debug("Exiting ftpBackupFile method ...");
        return $NOLOGIN;
    }
    // upload the file
    $destination_file = basename($source_file);
    $upload = ftp_put($conn_id, $destination_file, $source_file, FTP_BINARY);
    // check upload status
    if (!$upload) {
        ftp_close($conn_id);
        $log->debug("Exiting ftpBackupFile method ...");
        return $NOUPLOAD;
    }
    // close the FTP stream
    ftp_close($conn_id);
    $log->debug("Exiting ftpBackupFile method ...");
    return $FTPOK;
}
Esempio n. 15
0
 /**
  * @param $file
  * @return bool
  */
 function putFile($file)
 {
     $this->openConnection();
     $result = @ftp_put($this->getConnection(), $file, $file, FTP_ASCII);
     $this->closeConnection();
     return $result;
 }
Esempio n. 16
0
 /**
  * @inheritdoc
  */
 public function send($remoteFile, $localFile, $mode = FTP_BINARY)
 {
     if (false === ftp_put($this->getFtp(), $remoteFile, $localFile, $mode)) {
         throw new \Exception("Cant upload file on FTP server");
     }
     return true;
 }
Esempio n. 17
0
 function putFile($filename)
 {
     if (!$this->connection || !$this->login_result) {
         $this->connect();
     }
     $directories = dirname($filename);
     $file = basename($filename);
     $dir_array = explode('/', $directories);
     $empty = array_shift($dir_array);
     // Change into MIRROR_REMOTE_DIR.
     ftp_chdir($this->connection, MIRROR_REMOTE_DIR);
     // Create any folders that are needed.
     foreach ($dir_array as $dir) {
         // If it doesn't exist, create it.
         // Then chdir to it.
         if (@ftp_chdir($this->connection, $dir)) {
             // Do nothing.
         } else {
             if (ftp_mkdir($this->connection, $dir)) {
                 ftp_chmod($this->connection, 0775, $dir);
                 ftp_chdir($this->connection, $dir);
             } else {
                 NDebug::debug('Cannot create a folder via ftp.', N_DEBUGTYPE_INFO);
             }
         }
     }
     // Put the file into the folder.
     $full_path = $_SERVER['DOCUMENT_ROOT'] . $filename;
     if (ftp_put($this->connection, $file, $full_path, FTP_BINARY)) {
         ftp_chmod($this->connection, 0775, $file);
         NDebug::debug("FTP Mirror: {$filename} was uploaded successfully", N_DEBUGTYPE_INFO);
     } else {
         NDebug::debug("FTP Mirror: {$filename} was NOT uploaded successfully", N_DEBUGTYPE_INFO);
     }
 }
Esempio n. 18
0
 function _copyFile($sFilePathFrom, $sFilePathTo)
 {
     if (substr($sFilePathFrom, -1) == '*') {
         $sFilePathFrom = substr($sFilePathFrom, 0, -1);
     }
     $bResult = false;
     if (is_file($sFilePathFrom)) {
         if ($this->_isFile($sFilePathTo)) {
             $aFileParts = $this->_parseFile($sFilePathTo);
             if (isset($aFileParts[0])) {
                 $bRet = $this->_ftpMkDirR($aFileParts[0]);
             }
             $bResult = @ftp_put($this->_rStream, $sFilePathTo, $sFilePathFrom, FTP_BINARY);
         } else {
             if ($this->_isDirectory($sFilePathTo)) {
                 $bRet = $this->_ftpMkDirR($sFilePathTo);
                 $aFileParts = $this->_parseFile($sFilePathFrom);
                 if (isset($aFileParts[1])) {
                     $bResult = @ftp_put($this->_rStream, $this->_validatePath($sFilePathTo) . $aFileParts[1], $sFilePathFrom, FTP_BINARY);
                 }
             }
         }
     } else {
         if (is_dir($sFilePathFrom) && $this->_isDirectory($sFilePathTo)) {
             $bRet = $this->_ftpMkDirR($sFilePathTo);
             $aInnerFiles = $this->_readDirectory($sFilePathFrom);
             foreach ($aInnerFiles as $sFile) {
                 $bResult = $this->_copyFile($this->_validatePath($sFilePathFrom) . $sFile, $this->_validatePath($sFilePathTo) . $sFile);
             }
         } else {
             $bResult = false;
         }
     }
     return $bResult;
 }
Esempio n. 19
0
File: Ftp.php Progetto: ssrsfs/blg
 public function put($remote, $local, $mode = FTP_BINARY)
 {
     if ($this->_ftpStream) {
         return ftp_put($this->_ftpStream, $remote, $local, $mode);
     }
     return false;
 }
Esempio n. 20
0
File: ftp.php Progetto: nopticon/mag
 public function ftp_put($remote_file, $local_file)
 {
     if (!file_exists($local_file)) {
         return false;
     }
     return @ftp_put($this->conn_id, $remote_file, $local_file, FTP_BINARY);
 }
Esempio n. 21
0
function upload()
{
    $ftp_server = "ftp.webcindario.com";
    $ftp_user_name = "nngg";
    $ftp_user_pass = "******";
    $destination_file = "./img/";
    $source_file = $_FILES['userfile']['tmp_name'];
    $source_name = $_FILES['userfile']['name'];
    $conn_id = ftp_connect($ftp_server);
    ftp_pasv($conn_id, true);
    $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
    if (!$conn_id || !$login_result) {
        echo "";
        echo "";
        exit;
    } else {
        echo "";
    }
    $upload = ftp_put($conn_id, $destination_file . $_FILES['userfile']['name'], $source_file, FTP_BINARY);
    if (!$upload) {
        echo "";
    } else {
        echo "";
    }
}
Esempio n. 22
0
 function upload($file, $filename)
 {
     $this->connect();
     $this->dir = FTP_DIR . $filename;
     $upload = ftp_put($this->conid, $this->dir, $file, FTP_BINARY);
     $ch = ftp_site($this->conid, "chmod 777 " . $this->dir);
     $this->disconnect();
 }
Esempio n. 23
0
 /**
  * upload file to remove FTP server
  * @param  string $remoteFile path and filename for remote file
  * @param  string $localFile  local path to file
  * @return string             message
  */
 function uploadFile($remoteFile, $localFile)
 {
     if (ftp_put($this->conn, $this->basePath . $remoteFile, $localFile, FTP_ASCII)) {
         return "<p>successfully uploaded {$localFile} to {$remoteFile}</p>\n";
     } else {
         return "<p>There was a problem while uploading {$remoteFile}</p>\n";
     }
 }
Esempio n. 24
0
 /** 上传文件
  * up_file function.
  *
  * @access public
  * @param mixed $path_local 本地路径
  * @param mixed $path_remote 远程路径
  * @return void
  */
 function up_file($path_local, $path_remote)
 {
     $_arr_dirRow = $this->mk_dir($path_remote);
     //建立目录
     $this->ftp_status = @ftp_put($this->ftp_conn, $path_remote, $path_local, FTP_BINARY);
     //上传
     return $this->ftp_status;
 }
Esempio n. 25
0
 protected function uploadFile($pathToLocalFile, $pathToRemoteFile)
 {
     //ftp_pasv($this->connection, true);
     $success = ftp_put($this->connection, $pathToRemoteFile, $pathToLocalFile, FTP_BINARY);
     if (!$success) {
         throw new \Exception(strtr('Could not upload the file "@local_file" to "@remote_file"', array('@local_file' => $pathToLocalFile, '@remote_file' => $pathToRemoteFile)));
     }
 }
Esempio n. 26
0
 public function upload(string $localPath, string $remotePath, string $type = 'ascii') : bool
 {
     if (ftp_put($this->connect, $remotePath, $localPath, Converter::toConstant($type, 'FTP_'))) {
         return true;
     } else {
         throw new FileRemoteUploadException($localPath);
     }
 }
Esempio n. 27
0
 private function put($local, $remote)
 {
     if ($this->chdir(dirname($remote)) === false) {
         return false;
     }
     $status = @ftp_put($this->connection, $remote, $local, FTP_BINARY);
     return $this->log('PUT', $local . ' ' . $remote, $status);
 }
Esempio n. 28
0
function dftp_put($ftp_stream, $remote_file, $local_file, $mode, $startpos = 0)
{
    $remote_file = wipespecial($remote_file);
    $local_file = wipespecial($local_file);
    $mode = intval($mode);
    $startpos = intval($startpos);
    return @ftp_put($ftp_stream, $remote_file, $local_file, $mode, $startpos);
}
Esempio n. 29
0
 /**
  * {@inheritdoc}
  */
 public function put(BucketInterface $bucket, $name, $source)
 {
     $location = $this->ensureLocation($bucket, $name);
     if (!ftp_put($this->connection, $location, $this->castFilename($source), FTP_BINARY)) {
         throw new ServerException("Unable to put '{$name}' to FTP server.");
     }
     return $this->refreshPermissions($bucket, $name);
 }
Esempio n. 30
0
 public function upload($serverpath, $localpath, $filename)
 {
     set_time_limit(0);
     $this->checkFolderExists($this->site->getPath() . '/' . $serverpath);
     ftp_pasv($this->connId, $this->passive);
     $ret = ftp_put($this->connId, $this->site->getPath() . '/' . $serverpath . '/' . $filename, $localpath, FTP_BINARY);
     set_time_limit(60);
 }