本文整理汇总了PHP中ftp_cdup函数的典型用法代码示例。如果您正苦于以下问题:PHP ftp_cdup函数的具体用法?PHP ftp_cdup怎么用?PHP ftp_cdup使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ftp_cdup函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: cd
/**
* Change Directory
* @param string $dir
* @return ftp
*
*/
public function cd($dir)
{
$dir = (string) $dir;
$dir === '..' ? ftp_cdup($this->ftp) : ftp_chdir($this->ftp, $dir);
$this->path = $this->pwd();
return $this;
}
开发者ID:shgysk8zer0,项目名称:core,代码行数:13,代码来源:ftp.php
示例2: download_file
function download_file($conn, $ftppath, $prjname)
{
$fn = ftp_rawlist($conn, $ftppath);
//列出该目录的文件名(含子目录),存储在数组中
foreach ($fn as $file) {
$b = explode(' ', $file);
$s = sizeof($b);
$file = $b[$s - 1];
if (preg_match('/^[a-zA-Z0-9_]+([a-zA-Z0-9-]*.*)(\\.+)/i', $file)) {
if (!file_exists($prjname . "/" . $file)) {
$fp = fopen($prjname . "/" . $file, "w");
}
if (ftp_get($conn, $prjname . "/" . $file, $ftppath . "/" . $file, FTP_BINARY)) {
echo "<br/>下载" . $prjname . "/" . $file . "成功<br/>";
} else {
echo "<br/>下载" . $prjname . "/" . $file . "失败<br/>";
}
} else {
if (!file_exists($prjname . "/" . $file)) {
echo "新建目录:" . $prjname . "/" . $file . "<br>";
mkdir(iconv("UTF-8", "GBK", $prjname . "/" . $file), 0777, true);
//本地机器上该目录不存在就创建一个
}
if (ftp_chdir($conn, $ftppath . "/" . $file)) {
chdir($prjname . "/" . $file);
}
$this->download_file($conn, $ftppath . "/" . $file, $prjname . "/" . $file);
//递归进入该目录下载文件
}
}
//foreach循环结束
ftp_cdup($conn);
//ftp服务器返回上层目录
chdir(dirname($prjname));
}
开发者ID:tiantuikeji,项目名称:fy,代码行数:35,代码来源:141231094405.PHP
示例3: removeDirectoryJailed
/**
* {@inheritdoc}
*/
protected function removeDirectoryJailed($directory)
{
$pwd = ftp_pwd($this->connection);
if (!ftp_chdir($this->connection, $directory)) {
throw new FileTransferException("Unable to change to directory @directory", NULL, array('@directory' => $directory));
}
$list = @ftp_nlist($this->connection, '.');
if (!$list) {
$list = array();
}
foreach ($list as $item) {
if ($item == '.' || $item == '..') {
continue;
}
if (@ftp_chdir($this->connection, $item)) {
ftp_cdup($this->connection);
$this->removeDirectory(ftp_pwd($this->connection) . '/' . $item);
} else {
$this->removeFile(ftp_pwd($this->connection) . '/' . $item);
}
}
ftp_chdir($this->connection, $pwd);
if (!ftp_rmdir($this->connection, $directory)) {
throw new FileTransferException("Unable to remove to directory @directory", NULL, array('@directory' => $directory));
}
}
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:29,代码来源:FTPExtension.php
示例4: cdup
function cdup()
{
$this->login();
$isok = ftp_cdup($this->link_id);
if ($isok) {
$this->dir = $this->pwd();
}
return $isok;
}
开发者ID:a195474368,项目名称:ejw,代码行数:9,代码来源:ftp.php
示例5: copy_file_to_ftp
function copy_file_to_ftp($idhash, $year, $month)
{
global $con;
// Returning to root path
ftp_cdup($con);
ftp_cdup($con);
// Check existing directory of year
navigate_to_dir($year);
// Check existing directory of month
navigate_to_dir($month);
// Copy file
$res = ftp_put($con, '/' . $year . '/' . $month . '/' . $idhash, IMGS_PATH . $idhash, FTP_BINARY);
if (!$res) {
// We in cycle for upload few images - if got error - we'll continue, message only
$err = error_get_last();
printf("Could not upload file %s\r\n%s\r\n", $idhash, $err["message"]);
return false;
}
return true;
}
开发者ID:laiello,项目名称:cartonbank,代码行数:20,代码来源:functions.php
示例6: dir_mkdirs
/**
* 方法:生成目录
* @path -- 路径
*/
function dir_mkdirs($path)
{
$path_arr = explode('/', $path);
// 取目录数组
$file_name = array_pop($path_arr);
// 弹出文件名
$path_div = count($path_arr);
// 取层数
foreach ($path_arr as $val) {
if (@ftp_chdir($this->conn_id, $val) == FALSE) {
$tmp = @ftp_mkdir($this->conn_id, $val);
if ($tmp == FALSE) {
echo "目录创建失败,请检查权限及路径是否正确!";
exit;
}
@ftp_chdir($this->conn_id, $val);
}
}
for ($i = 1; $i = $path_div; $i++) {
@ftp_cdup($this->conn_id);
}
}
开发者ID:nick198205,项目名称:yiqixiu,代码行数:26,代码来源:Ftp.class.php
示例7: copyFileViaFtp
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;
}
开发者ID:Nolfneo,项目名称:docvert,代码行数:39,代码来源:ftp.php
示例8: ftp_myexec2
function ftp_myexec2($ftp, $list)
{
global $ftp_log, $ftp_error, $lang;
// getting current directory
$root_dir = @ftp_pwd($ftp);
if ($root_dir === false) {
$ftp_log[] = $ftp_error = $lang['xs_ftp_log_nopwd'];
return false;
}
$current_dir = strlen($root_dir) ? $root_dir . '/' : '';
// run commands
for ($i = 0; $i < count($list); $i++) {
$item = $list[$i];
if ($item['command'] == 'mkdir') {
// create new directory
$res = @ftp_mkdir($ftp, $item['dir']);
if (!$res) {
$ftp_log[] = $ftp_error = str_replace('{DIR}', $item['dir'], $lang['xs_ftp_log_nomkdir']);
if (empty($item['ignore'])) {
return false;
}
} else {
$ftp_log[] = str_replace('{DIR}', $item['dir'], $lang['xs_ftp_log_mkdir']);
}
} elseif ($item['command'] == 'chdir') {
// change current directory
$res = @ftp_chdir($ftp, $item['dir']);
if (!$res) {
$ftp_log[] = $ftp_error = str_replace('{DIR}', $item['dir'], $lang['xs_ftp_log_nochdir']);
if (empty($item['ignore'])) {
return false;
}
} else {
$ftp_log[] = str_replace('{DIR}', $item['dir'], $lang['xs_ftp_log_chdir']);
}
} elseif ($item['command'] == 'cdup') {
// change current directory
$res = @ftp_cdup($ftp);
if (!$res) {
$ftp_log[] = $ftp_error = str_replace('{DIR}', '..', $lang['xs_ftp_log_nochdir']);
if (empty($item['ignore'])) {
return false;
}
} else {
$ftp_log[] = str_replace('{DIR}', '..', $lang['xs_ftp_log_chdir']);
}
} elseif ($item['command'] == 'rmdir') {
// remove directory
$res = @ftp_rmdir($ftp, $item['dir']);
if (!$res) {
$ftp_log[] = $ftp_error = str_replace('{DIR}', $item['dir'], $lang['xs_ftp_log_normdir']);
if (empty($item['ignore'])) {
return false;
}
} else {
$ftp_log[] = str_replace('{DIR}', $item['dir'], $lang['xs_ftp_log_rmdir']);
}
} elseif ($item['command'] == 'upload') {
// upload file
$res = @ftp_put($ftp, $current_dir . $item['remote'], $item['local'], FTP_BINARY);
if (!$res) {
$ftp_log[] = $ftp_error = str_replace('{FILE}', $item['remote'], $lang['xs_ftp_log_noupload']);
if (empty($item['ignore'])) {
return false;
}
} else {
$ftp_log[] = str_replace('{FILE}', $item['remote'], $lang['xs_ftp_log_upload']);
}
} elseif ($item['command'] == 'chmod') {
// upload file
$res = @ftp_chmod($ftp, $item['mode'], $current_dir . $item['file']);
if (!$res) {
$ftp_log[] = str_replace('{FILE}', $item['file'], $lang['xs_ftp_log_nochmod']);
if (empty($item['ignore'])) {
return false;
}
} else {
$ftp_log[] = str_replace(array('{FILE}', '{MODE}'), array($item['file'], $item['mode']), $lang['xs_ftp_log_chmod']);
}
} elseif ($item['command'] == 'exec') {
$res = ftp_myexec2($ftp, $item['list']);
if (!$res) {
return false;
}
} elseif ($item['command'] == 'removeall') {
ftp_remove_all($ftp);
} else {
$ftp_log[] = str_replace('{COMMAND}', $item['command'], $lang['xs_ftp_log_invalidcommand']);
if (empty($item['ignore'])) {
return false;
}
}
}
// changing current directory back
$ftp_log[] = str_replace('{DIR}', $root_dir, $lang['xs_ftp_log_chdir2']);
if (!@ftp_chdir($ftp, $root_dir)) {
$ftp_log[] = $ftp_error = str_replace('{DIR}', $root_dir, $lang['xs_ftp_log_nochdir2']);
return false;
}
return true;
//.........这里部分代码省略.........
开发者ID:Nekrofage,项目名称:FJR,代码行数:101,代码来源:xs_include.php
示例9: chdir
/**
* Change Directory
*
* @param string $dir New directory
* @return @e void
* @throws Exception CHDIR_FAILED
*/
public function chdir($dir)
{
if ($dir == '..') {
$currentDir = @ftp_pwd($this->stream);
$chdir = @ftp_cdup($this->stream);
if ($currentDir === @ftp_pwd($this->stream)) {
$chdir = false;
}
} elseif (substr($dir, 0, 1) !== '/') {
$dir = $this->directory . '/' . $dir;
$chdir = @ftp_chdir($this->stream, $dir);
} else {
$chdir = @ftp_chdir($this->stream, $dir);
}
if (!$chdir) {
throw new Exception('CHDIR_FAILED');
}
$this->directory = @ftp_pwd($this->stream);
}
开发者ID:ConnorChristie,项目名称:GrabViews-Live,代码行数:26,代码来源:classFtp.php
示例10: parentDir
/**
* Changes to the parent directory on the remote FTP server.
*
* @return boolean
*/
public function parentDir()
{
if ($this->getActive()) {
// Move up!
if (ftp_cdup($this->_connection)) {
return true;
} else {
return false;
}
} else {
throw new CDbException('EFtpComponent is inactive and cannot perform any FTP operations.');
}
}
开发者ID:mudiman,项目名称:yiirestintegrated,代码行数:18,代码来源:EFtpComponent.php
示例11: test
/**
* Tests FTP server
*
* @param string $error
* @return boolean
*/
function test(&$error)
{
if (!parent::test($error)) {
return false;
}
$rand = md5(time());
$tmp_dir = 'test_dir_' . $rand;
$tmp_file = 'test_file_' . $rand;
$tmp_path = W3TC_CACHE_TMP_DIR . '/' . $tmp_file;
if (!@file_put_contents($tmp_path, $rand)) {
$error = sprintf('Unable to create file: %s.', $tmp_path);
return false;
}
if (!$this->_connect($error)) {
return false;
}
$this->_set_error_handler();
if (!@ftp_mkdir($this->_ftp, $tmp_dir)) {
$error = sprintf('Unable to make directory: %s (%s).', $tmp_dir, $this->_get_last_error());
@unlink($tmp_path);
$this->_restore_error_handler();
$this->_disconnect();
return false;
}
if (file_exists($this->_config['docroot'] . '/' . $tmp_dir)) {
$error = sprintf('Test directory was made in your site root, not on separate FTP host or path. Change path or FTP information: %s.', $tmp_dir);
@unlink($tmp_path);
@ftp_rmdir($this->_ftp, $tmp_dir);
$this->_restore_error_handler();
$this->_disconnect();
return false;
}
if (!@ftp_chdir($this->_ftp, $tmp_dir)) {
$error = sprintf('Unable to change directory to: %s (%s).', $tmp_dir, $this->_get_last_error());
@unlink($tmp_path);
@ftp_rmdir($this->_ftp, $tmp_dir);
$this->_restore_error_handler();
$this->_disconnect();
return false;
}
if (!@ftp_put($this->_ftp, $tmp_file, $tmp_path, FTP_BINARY)) {
$error = sprintf('Unable to upload file: %s (%s).', $tmp_path, $this->_get_last_error());
@unlink($tmp_path);
@ftp_cdup($this->_ftp);
@ftp_rmdir($this->_ftp, $tmp_dir);
$this->_restore_error_handler();
$this->_disconnect();
return false;
}
@unlink($tmp_path);
if (!@ftp_delete($this->_ftp, $tmp_file)) {
$error = sprintf('Unable to delete file: %s (%s).', $tmp_path, $this->_get_last_error());
@ftp_cdup($this->_ftp);
@ftp_rmdir($this->_ftp, $tmp_dir);
$this->_restore_error_handler();
$this->_disconnect();
return false;
}
@ftp_cdup($this->_ftp);
if (!@ftp_rmdir($this->_ftp, $tmp_dir)) {
$error = sprintf('Unable to remove directory: %s (%s).', $tmp_dir, $this->_get_last_error());
$this->_restore_error_handler();
$this->_disconnect();
return false;
}
$this->_restore_error_handler();
$this->_disconnect();
return true;
}
开发者ID:trendyta,项目名称:bestilblomster,代码行数:75,代码来源:Ftp.php
示例12: mkdir
/**
* 目录生成(支持递归)
*
* @access public
* @param string 目录标识(ftp)
* @return boolean
*/
public function mkdir($path = '', $permissions = NULL)
{
if ($path == '' or !$this->_isconn()) {
return FALSE;
}
if ($path[strlen($path) - 1] != '/') {
$path .= '/';
}
$path_arr = explode('/', $path);
// 取目录数组
$file_name = array_pop($path_arr);
// 弹出文件名
$path_div = count($path_arr);
// 取层数
foreach ($path_arr as $val) {
if (@ftp_chdir($this->conn_id, $val) == FALSE) {
$result = @ftp_mkdir($this->conn_id, $val);
if ($result == FALSE) {
if ($this->debug === TRUE) {
$this->_error("ftp_unable_to_mkdir:dir[" . $path . "]");
}
return FALSE;
}
@ftp_chdir($this->conn_id, $val);
}
}
for ($i = 1; $i <= $path_div; $i++) {
@ftp_cdup($this->conn_id);
}
if (!is_null($permissions)) {
$this->chmod($path, (int) $permissions);
}
return TRUE;
}
开发者ID:h3len,项目名称:Project,代码行数:41,代码来源:ftp.class.php
示例13: deleteFolder
function deleteFolder($folder, $path)
{
global $conn_id;
global $lang_cant_delete;
global $lang_folder_doesnt_exist;
global $lang_folder_cant_delete;
$isError = 0;
// List contents of folder
if ($path != "/" && $path != "~") {
$folder_path = $path . "/" . $folder;
} else {
if ($_SESSION["win_lin"] == "lin" || $_SESSION["win_lin"] == "mac") {
if ($_SESSION["dir_current"] == "/") {
$folder_path = "/" . $folder;
}
}
if ($_SESSION["dir_current"] == "~") {
$folder_path = "~/" . $folder;
}
if ($_SESSION["win_lin"] == "win") {
$folder_path = "/" . $folder;
}
}
$ftp_rawlist = getFtpRawList($folder_path);
// Go through array of files/folders
if (sizeof($ftp_rawlist) > 0) {
$count = 0;
foreach ($ftp_rawlist as $ff) {
$count++;
// Split up array into values (Lin)
if ($_SESSION["win_lin"] == "lin") {
$ff = preg_split("/[\\s]+/", $ff, 9);
$perms = $ff[0];
$file = $ff[8];
if (getFileType($perms) == "d") {
$isFolder = 1;
} else {
$isFolder = 0;
}
}
// Split up array into values (Mac)
// skip first line
if ($_SESSION["win_lin"] == "mac") {
if ($count == 1) {
continue;
}
$ff = preg_split("/[\\s]+/", $ff, 9);
$perms = $ff[0];
$file = $ff[8];
if (getFileType($perms) == "d") {
$isFolder = 1;
} else {
$isFolder = 0;
}
}
// Split up array into values (Win)
if ($_SESSION["win_lin"] == "win") {
$ff = preg_split("/[\\s]+/", $ff, 4);
$size = $ff[2];
$file = $ff[3];
if ($size == "<DIR>") {
$isFolder = 1;
} else {
$isFolder = 0;
}
}
if ($file != "." && $file != "..") {
// Check for sub folders and then perform this function
if ($isFolder == 1) {
deleteFolder($file, $folder_path);
} else {
// otherwise delete file
$file_path = $folder_path . "/" . $file;
if (!@ftp_delete($conn_id, "" . $file_path . "")) {
if (checkFirstCharTilde($file_path) == 1) {
if (!@ftp_delete($conn_id, "" . replaceTilde($file_path) . "")) {
recordFileError("file", replaceTilde($file_path), $lang_cant_delete);
}
} else {
recordFileError("file", $file_path, $lang_cant_delete);
}
}
}
}
}
}
// Check if file exists
if (checkFileExists("d", $folder, $folder_path) == 1) {
$_SESSION["errors"][] = str_replace("[file]", "<strong>" . tidyFolderPath($folder_path, $folder) . "</strong>", $lang_folder_doesnt_exist);
} else {
// Chage dir up before deleting
ftp_cdup($conn_id);
// Delete the empty folder
if (!@ftp_rmdir($conn_id, "" . $folder_path . "")) {
if (checkFirstCharTilde($folder_path) == 1) {
if (!@ftp_rmdir($conn_id, "" . replaceTilde($folder_path) . "")) {
recordFileError("folder", replaceTilde($folder_path), $lang_folder_cant_delete);
$isError = 1;
}
} else {
//.........这里部分代码省略.........
开发者ID:joyeop,项目名称:Monsta-FTP,代码行数:101,代码来源:index.php
示例14: ftp_isdir
/**
* Tell if an entry is a FTP directory
*
* @param resource $connect_id Connection handler
* @param string $dir Directory
* @return int 1=directory, 0=not a directory
*/
function ftp_isdir($connect_id, $dir)
{
if (@ftp_chdir($connect_id, $dir)) {
ftp_cdup($connect_id);
return 1;
} else {
return 0;
}
}
开发者ID:nrjacker4,项目名称:crm-php,代码行数:16,代码来源:index.php
示例15: _ftpMkDirR
function _ftpMkDirR($sPath)
{
$sPwd = ftp_pwd($this->_rStream);
$aParts = explode("/", $sPath);
$sPathFull = '';
if ('/' == $sPath[0]) {
$sPathFull = '/';
ftp_chdir($this->_rStream, '/');
}
foreach ($aParts as $sPart) {
if (!$sPart) {
continue;
}
$sPathFull .= $sPart;
if ('..' == $sPart) {
@ftp_cdup($this->_rStream);
} elseif (!@ftp_chdir($this->_rStream, $sPart)) {
if (!@ftp_mkdir($this->_rStream, $sPart)) {
ftp_chdir($this->_rStream, $sPwd);
return false;
}
@ftp_chdir($this->_rStream, $sPart);
}
$sPathFull .= '/';
}
ftp_chdir($this->_rStream, $sPwd);
return true;
}
开发者ID:Prashank25,项目名称:dolphin.pro,代码行数:28,代码来源:BxDolFtp.php
示例16: fel
function fel($connid)
{
ftp_cdup($connid);
$p = ftp_pwd($connid);
return $p;
}
开发者ID:DeteCT0R,项目名称:gts-minicp,代码行数:6,代码来源:funkciok.php
示例17: build_row
echo "<TR><TH COLSPAN=13>";
echo "<CENTER><B><FONT color=" . $warn_color[$sess_Data["level"]] . ">";
echo $sess_Data["warn"];
echo "</FONT></B></CENTER>";
echo "<P>";
echo "</TH></TR>";
$sess_Data["warn"] = "";
}
// display link to the home directory
$built_data = build_row($show_col, array('', '', '', '', '', '', '', '', sprintf("~ (%s)", gettext("Home Directory"))), "D", $home_Dir);
$home = display_row($built_data, $alt_class[$alt_row % 2], "disabled");
echo "{$home}";
$alt_row = $alt_row + 1;
// display the link to the parent directory if there is one
if (ftp_pwd($fp) != "/") {
ftp_cdup($fp);
$NEWDIR = urlencode(ftp_pwd($fp));
// display the .. directory
$built_data = build_row($show_col, array('', '', '', '', '', '', '', '', sprintf(".. (%s)", gettext("Up One Directory"))), "D", "..");
$cdup = display_row($built_data, $alt_class[$alt_row % 2], "disabled");
echo "{$cdup}";
$alt_row = $alt_row + 1;
}
if ($files != FALSE) {
// this is testing for whether the ftp_rawlist starts with the dir total
// or a directory/file, $index is the index for the files[] array
if (count(explode(" ", $files[0])) == 2) {
$index = 1;
} else {
$index = 0;
}
开发者ID:BackupTheBerlios,项目名称:vhcs-svn,代码行数:31,代码来源:ftp.php
示例18: cdup
/**
* Changes to the parent directory
* @link http://php.net/ftp_cdup
*
* @return boolean TRUE on success FALSE on failure
*/
public function cdup()
{
return ftp_cdup($this->connection->getStream());
}
开发者ID:ringfreejohn,项目名称:pbxframework,代码行数:10,代码来源:FTPWrapper.php
示例19: levelUp
/**
* Change to the parent directory
*
* @return bool
*/
public function levelUp()
{
if (is_resource($this->cid)) {
return ftp_cdup($this->cid);
}
}
开发者ID:bergi9,项目名称:2Moons,代码行数:11,代码来源:ftp.class.php
示例20: cdup
/**
* ftp_cdup wrapper
*
* @return bool
*/
public function cdup()
{
$this->checkConnected();
return @ftp_cdup($this->_conn);
}
开发者ID:chucky515,项目名称:Magento-CE-Mirror,代码行数:10,代码来源:Ftp.php
注:本文中的ftp_cdup函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论