本文整理汇总了PHP中ftp_close函数的典型用法代码示例。如果您正苦于以下问题:PHP ftp_close函数的具体用法?PHP ftp_close怎么用?PHP ftp_close使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ftp_close函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: DeleteUpfile
function DeleteUpfile($R, $d)
{
global $g, $table;
$UPFILES = getArrayString($R['upload']);
foreach ($UPFILES['data'] as $_val) {
$U = getUidData($table['s_upload'], $_val);
if ($U['uid']) {
if ($U['url'] == $d['comment']['ftp_urlpath']) {
$FTP_CONNECT = ftp_connect($d['comment']['ftp_host'], $d['comment']['ftp_port']);
$FTP_CRESULT = ftp_login($FTP_CONNECT, $d['comment']['ftp_user'], $d['comment']['ftp_pass']);
if ($d['comment']['ftp_pasv']) {
ftp_pasv($FTP_CONNECT, true);
}
if (!$FTP_CONNECT) {
getLink('', '', 'FTP서버 연결에 문제가 발생했습니다.', '');
}
if (!$FTP_CRESULT) {
getLink('', '', 'FTP서버 아이디나 패스워드가 일치하지 않습니다.', '');
}
ftp_delete($FTP_CONNECT, $d['comment']['ftp_folder'] . $U['folder'] . '/' . $U['tmpname']);
if ($U['type'] == 2) {
ftp_delete($FTP_CONNECT, $d['comment']['ftp_folder'] . $U['folder'] . '/' . $U['thumbname']);
}
ftp_close($FTP_CONNECT);
} else {
unlink($U['url'] . $U['folder'] . '/' . $U['tmpname']);
if ($U['type'] == 2) {
unlink($U['url'] . $U['folder'] . '/' . $U['thumbname']);
}
}
getDbDelete($table['s_upload'], 'uid=' . $U['uid']);
}
}
}
开发者ID:kieregh,项目名称:test_comment,代码行数:34,代码来源:action.func.php
示例2: xmlFtpTest
public function xmlFtpTest($xmlFileID)
{
$ftp_server = "117.55.235.145";
$conn_id = ftp_connect($ftp_server);
$ftp_user_name = "s1057223";
$ftp_user_pass = "526Ge0P4Ck8Jd937";
// 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);
}
开发者ID:ianliu2015,项目名称:DocsLiquor,代码行数:30,代码来源:DataSyncController.php
示例3: ftp_put_file
function ftp_put_file($remote, $local)
{
$ftp_host = 'xungeng.vpaas.net';
$ftp_user = 'root';
$ftp_pass = 'zehin@123';
$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);
}
开发者ID:xinyflove,项目名称:MyPHPFunction,代码行数:31,代码来源:ftp_put_file.php
示例4: close
public function close()
{
if ($this->connected) {
return ftp_close($this->handle);
}
return false;
}
开发者ID:xpence,项目名称:portfolio,代码行数:7,代码来源:FTP.php
示例5: JSX_PHP_FTP_Directory_List_Get
function JSX_PHP_FTP_Directory_List_Get($p_aConnData, $p_aPathData)
{
// Connection settings.
$hostname = $p_aConnData['hostname'];
$username = $p_aConnData['username'];
$password = $p_aConnData['password'];
// Directory settings.
$startdir = $p_aPathData['startdir'];
// absolute path
$suffix = $p_aPathData['suffix'];
// suffixes to list
$g_levello = $p_aPathData['levello'];
// Livello di "nested directory".
// Data array.
$files = array();
// Ftp connection.
$conn_id = ftp_connect($hostname);
$login = ftp_login($conn_id, $username, $password);
if (!$conn_id) {
echo 'Wrong server!';
exit;
} else {
if (!$login) {
echo 'Wrong username/password!';
exit;
} else {
// Get data through FTP.
$files = JSX_PHP_FTP_raw_list($conn_id, $p_aConnData, $p_aPathData, $files);
}
}
// Close FTP connection.
ftp_close($conn_id);
// Return value.
return $files;
}
开发者ID:XrosaXasorX,项目名称:PHP_FTP_FileSystem_RecursiveScan,代码行数:35,代码来源:jsx_include_php.php
示例6: ftpBackupFile
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;
}
开发者ID:casati-dolibarr,项目名称:corebos,代码行数:35,代码来源:ftp.php
示例7: test_connection
function test_connection()
{
if ($this->input->is_ajax_request()) {
header('Content-Type: application/json', true);
$ftp_server = trim($this->input->post('address'));
$ftp_user = trim($this->input->post('user'));
$ftp_password = trim($this->input->post('password'));
$port = trim($this->input->post('port'));
// set up basic connection
if ($this->input->post('SFTP') == true) {
$conn_id = @ftp_ssl_connect($ftp_server, $port) or die(json_encode(array('status' => 'error', 'output' => '<span class="delete ftp-alert cmsicon" style="display: inline-block;float: none;"></span> Couldn\'t connect to ' . $ftp_server)));
} else {
$conn_id = @ftp_connect($ftp_server, $port) or die(json_encode(array('status' => 'error', 'output' => '<span class="delete ftp-alert cmsicon" style="display: inline-block;float: none;"></span> Couldn\'t connect to ' . $ftp_server)));
}
// login with username and password
if (!@ftp_login($conn_id, $ftp_user, $ftp_password)) {
$output = array('status' => 'error', 'output' => '<span class="cus-cross-octagon"></span> Username and Password is incorrect');
} else {
$output = array('status' => 'success', 'output' => '<span class="cus-accept"></span> Connection OK!');
}
ftp_close($conn_id);
echo json_encode($output);
} else {
show_404();
}
}
开发者ID:braxtondiggs,项目名称:Clefable,代码行数:26,代码来源:ftp.php
示例8: close
/**
* Closes an FTP connection
*
* @return boolean Returns true on success or false on failure
*/
public function close()
{
$result = ftp_close($this->connection);
$this->connection = null;
$this->loggedIn = false;
return $result;
}
开发者ID:socialweb,项目名称:PiGo,代码行数:12,代码来源:FtpConnection.php
示例9: Authenticate
/**
* Tries to logon to the FTP server with given id and password
*
* @access public
*
* @param string $source Authentication source to be used
* @param string $external_uid The ID entered
* @param string $external_passwd The password of the user
*
* @return boolean True if the authentication was a success, false
* otherwise
*/
public function Authenticate($source, $external_uid, $external_passwd)
{
$enc = ExternalAuthenticator::getAuthEnc($source);
$port = ExternalAuthenticator::getAuthPort($source);
if (is_null($port)) {
$port = self::$port;
}
ExternalAuthenticator::AuthLog($external_uid . '.ftp - Connecting to ' . ExternalAuthenticator::getAuthServer($source) . ' port ' . $port);
if ($enc == 'ssl') {
ExternalAuthenticator::AuthLog($external_uid . '.ftp - Connection type is SSL');
$conn = @ftp_ssl_connect(ExternalAuthenticator::getAuthServer($source), $port);
} else {
$conn = @ftp_connect(ExternalAuthenticator::getAuthServer($source), $port);
}
if (!$conn) {
ExternalAuthenticator::AuthLog($external_uid . '.ftp - Connection to server failed');
ExternalAuthenticator::setAuthMessage(_t('FTP_Authenticator.NoConnect', 'Could not connect to FTP server'));
return false;
} else {
ExternalAuthenticator::AuthLog($external_uid . '.ftp - Connection to server succeeded');
}
if (!@ftp_login($conn, $external_uid, $external_passwd)) {
ExternalAuthenticator::AuthLog($external_uid . '.ftp - User credentials failed at ftp server');
ftp_close($conn);
ExternalAuthenticator::setAuthMessage(_t('ExternalAuthenticator.Failed'));
return false;
} else {
ExternalAuthenticator::AuthLog($external_uid . '.ftp - ftp server validated credentials');
ftp_close($conn);
return true;
}
}
开发者ID:hamishcampbell,项目名称:silverstripe-auth-external,代码行数:44,代码来源:FTP.php
示例10: generate
public function generate($log)
{
global $db;
$host = "ftp.mozilla.org";
$hostpos = strpos($this->logURL, $host);
if ($hostpos === false) {
throw new Exception("Log file {$this->logURL} not hosted on {$host}!");
}
$path = substr($this->logURL, $hostpos + strlen($host) + strlen("/"));
$ftpstream = @ftp_connect($host);
if (!@ftp_login($ftpstream, "anonymous", "")) {
throw new Exception("Couldn't connect to Mozilla FTP server.");
}
$fp = tmpfile();
if (!@ftp_fget($ftpstream, $fp, $path, FTP_BINARY)) {
throw new Exception("Log not available at URL {$this->logURL}.");
}
ftp_close($ftpstream);
rewind($fp);
$db->beginTransaction();
$stmt = $db->prepare("\n UPDATE runs_logs\n SET content = :content\n WHERE buildbot_id = :id AND type = :type;");
$stmt->bindParam(":content", $fp, PDO::PARAM_LOB);
$stmt->bindParam(":id", $log['_id']);
$stmt->bindParam(":type", $log['type']);
$stmt->execute();
$db->commit();
fclose($fp);
}
开发者ID:rhelmer,项目名称:tbpl,代码行数:28,代码来源:RawGzLogDownloader.php
示例11: ftpMkDir
function ftpMkDir($path, $newDir, $ftpServer, $ftpUser, $ftpPass)
{
$server = $ftpServer;
// ftp server
$connection = ftp_connect($server);
// connection
// login to ftp server
$user = $ftpUser;
$pass = $ftpPass;
$result = ftp_login($connection, $user, $pass);
// check if connection was made
if (!$connection || !$result) {
return false;
exit;
} else {
ftp_chdir($connection, $path);
// go to destination dir
if (ftp_mkdir($connection, $newDir)) {
// create directory
return $newDir;
} else {
return false;
}
ftp_close($connection);
// close connection
}
}
开发者ID:utilo-web-app-development,项目名称:REZERVI,代码行数:27,代码来源:filesAndFolders.inc.php
示例12: __destruct
public function __destruct()
{
if ($this->_ftpStream) {
// close FTP connection
@ftp_close($this->_ftpStream);
}
}
开发者ID:OpenE2,项目名称:enigma2-php,代码行数:7,代码来源:enigma2.php
示例13: ftp_image_close
static function ftp_image_close()
{
if (ImageLib::$ftp_image_connect_id) {
ftp_close(ImageLib::$ftp_image_connect_id);
ImageLib::$ftp_image_connect_id = false;
}
}
开发者ID:duynhan07,项目名称:elink,代码行数:7,代码来源:ImageLib.php
示例14: get_file
/**
* Function that retrieves a file from FTP library and compress it if necessary
*
* @param string $file File name to be retrieved from FTP library
* @return boolean
*/
public function get_file($file, $dir = '')
{
if (!defined("LOCATION") || !defined("CODE") || !defined("LIBRARY") || !defined("CACHE_PATH")) {
$this->container->__error("Imposible recuperar el archivo remoto: falta alguna constante por definir");
return false;
}
$cnn = ftp_connect(LOCATION);
$rs = ftp_login($cnn, LIBRARY, CODE);
if ($rs === false) {
$this->container->__error("Imposible conectar a la libreria de funciones!");
}
$dir = $dir == '' ? '' : $dir . DIRECTORY_SEPARATOR;
ftp_chdir($cnn, LIBRARY . DIRECTORY_SEPARATOR . $dir);
if (@ftp_chdir($cnn, $file) !== false) {
if ($this->container->__debug()) {
@mkdir(CACHE_PATH . $dir . $file);
chmod(CACHE_PATH . $dir . $file, 0777);
$dir = $dir == '' ? $file : $dir . $file;
} else {
@mkdir(CACHE_PATH . $dir . md5($file));
chmod(CACHE_PATH . $dir . md5($file), 0777);
$dir = $dir == '' ? $file : $dir . $file;
}
$files = ftp_nlist($cnn, ".");
foreach ($files as $filea) {
$this->get_file($filea, $dir);
}
return true;
} else {
if ($file == '.' || $file == '..') {
return;
}
if ($this->container->__debug()) {
$aux = ftp_get($cnn, CACHE_PATH . $dir . $file, $file, FTP_BINARY);
} else {
$temp = explode(DIRECTORY_SEPARATOR, $dir);
array_walk($temp, function (&$element, $index) {
$element = md5($element);
});
array_pop($temp);
$temp = implode(DIRECTORY_SEPARATOR, $temp) . DIRECTORY_SEPARATOR;
$aux = ftp_get($cnn, CACHE_PATH . $temp . md5($file), $file, FTP_BINARY);
}
if (!$aux) {
ftp_close($cnn);
$this->container->__error("Imposible obtener el archivo para cache: " . $file);
return false;
} else {
ftp_close($cnn);
if ($this->container->__debug()) {
chmod(CACHE_PATH . $dir . $file, 0777);
$this->compress_cache_file($dir . $file);
} else {
chmod(CACHE_PATH . $temp . md5($file), 0777);
$this->compress_cache_file($temp . md5($file));
}
return true;
}
}
}
开发者ID:fran-diaz,项目名称:ite,代码行数:66,代码来源:cache.php
示例15: subida_script
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);
}
开发者ID:nuwem,项目名称:fitness,代码行数:30,代码来源:libconfig.php
示例16: reconnect
/**
* Reconnects to FTP server.
* @return void
*/
public function reconnect()
{
@ftp_close($this->resource);
foreach ($this->state as $name => $args) {
call_user_func_array(array($this, $name), $args);
}
}
开发者ID:humor-zo,项目名称:chaofan,代码行数:11,代码来源:ftp.class.php
示例17: downloadFile
public function downloadFile()
{
$requestURL = trim(Mage::getStoreConfig('pulliver/western_power/base_url'), ' /');
$username = Mage::getStoreConfig('pulliver/western_power/username');
$password = Mage::getStoreConfig('pulliver/western_power/password');
$connection = ftp_connect($requestURL);
if (!$connection) {
Vikont_Pulliver_Helper_Data::inform(sprintf('Could not connect to %s', $requestURL));
}
if (!@ftp_login($connection, $username, $password)) {
Vikont_Pulliver_Helper_Data::throwException(sprintf('Error logging to FTP %s as %s', $requestURL, $username));
}
$remoteFileName = Mage::getStoreConfig('pulliver/western_power/remote_filename');
$localFileName = $this->getLocalFileName($remoteFileName, 'downloaded/');
if (file_exists($localFileName)) {
@unlink($localFileName);
} else {
if (!file_exists($dirName = dirname($localFileName))) {
mkdir($dirName, 0777, true);
}
}
Vikont_Pulliver_Helper_Data::type("Downloading {$requestURL}/{$remoteFileName}...");
$startedAt = time();
if (!ftp_get($connection, $localFileName, $remoteFileName, FTP_BINARY)) {
Vikont_Pulliver_Helper_Data::throwException(sprintf('Error downloading from FTP %s/%s to %s', $requestURL, $remoteFileName, $localFileName));
}
ftp_close($connection);
$timeTaken = time() - $startedAt;
Vikont_Pulliver_Helper_Data::inform(sprintf('Inventory successfully downloaded from %s/%s to %s, size=%dbytes, time=%ds', $requestURL, $remoteFileName, $localFileName, filesize($localFileName), $timeTaken));
return $localFileName;
}
开发者ID:rcclaudrey,项目名称:dev,代码行数:31,代码来源:WesternPower.php
示例18: save
/**
* 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;
}
开发者ID:rtsantos,项目名称:mais,代码行数:41,代码来源:Attachment.php
示例19: run
/**
* @inheritdoc
*/
public function run(&$cmdParams, &$params)
{
$controller = $this->controller;
$res = false;
$connectionId = !empty($cmdParams[0]) ? $cmdParams[0] : '';
if (empty($connectionId)) {
Log::throwException('sftpDisconnect: Please specify a valid connection id');
}
/** @noinspection PhpUndefinedMethodInspection (provided by the SftpConnectReqs Behavior) */
$connParams = $controller->getConnectionParams($connectionId);
$controller->stdout(" " . $connectionId . " ", $connParams['sftpLabelColor'], Console::FG_BLACK);
$controller->stdout(' Closing connection ');
if (!$controller->dryRun) {
// the getConnection method is provided by the SftpConnectReqs Behavior
/** @noinspection PhpUndefinedMethodInspection */
/** @var $connection Net_SFTP|resource */
$connection = $controller->getConnection($connectionId);
switch ($connParams['sftpConnectionType']) {
case SftpHelper::TYPE_SFTP:
$connection->disconnect();
break;
case SftpHelper::TYPE_FTP:
ftp_close($connection);
break;
default:
$controller->stdout("\n");
Log::throwException('Unsupported connection type: ' . $connParams['sftpConnectionType']);
break;
}
} else {
$controller->stdout(' [dry run]', Console::FG_YELLOW);
}
$controller->stdout("\n");
return $res;
}
开发者ID:giovdk21,项目名称:deployii,代码行数:38,代码来源:SftpDisconnectCommand.php
示例20: uploadPackageToFTP
private function uploadPackageToFTP($account)
{
$connection = @ftp_connect($account['host']);
if (!$connection) {
cmsUser::addSessionMessage(LANG_CP_FTP_AUTH_FAILED, 'error');
return false;
}
$session = @ftp_login($connection, $account['user'], $account['pass']);
if (!$session) {
cmsUser::addSessionMessage(LANG_CP_FTP_AUTH_FAILED, 'error');
return false;
}
if ($account['is_pasv']) {
ftp_pasv($connection, true);
}
if (!$this->checkDestination($connection, $account)) {
return false;
}
$src_dir = $this->getPackageContentsDir();
$dst_dir = '/' . trim($account['path'], '/');
try {
$this->uploadDirectoryToFTP($connection, $src_dir, $dst_dir);
} catch (Exception $e) {
ftp_close($connection);
cmsUser::addSessionMessage($e->getMessage(), 'error');
return false;
}
ftp_close($connection);
$this->redirectToAction('install/finish');
return true;
}
开发者ID:asphix,项目名称:icms2,代码行数:31,代码来源:install_ftp.php
注:本文中的ftp_close函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论