本文整理汇总了PHP中ftp_pwd函数的典型用法代码示例。如果您正苦于以下问题:PHP ftp_pwd函数的具体用法?PHP ftp_pwd怎么用?PHP ftp_pwd使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ftp_pwd函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: connect
public function connect()
{
$this->printLog("Connect");
if ($this->conn_id = ftp_connect($this->host, $this->port, $this->timeout)) {
if (ftp_login($this->conn_id, $this->user, $this->pass)) {
$this->updateState(PR_FTP_STATE_LOGGED_IN);
if ($status = ftp_chdir($this->conn_id, $this->cur_path)) {
$this->updateState(PR_FTP_STATE_TARGETED);
$this->updateStatus(PR_FTP_STATUS_READY);
$this->systype = ftp_systype($this->conn_id);
// TODO: make specific OS dependednt things
$this->printLog("OS: " . $this->systype . " " . ftp_pwd($this->conn_id));
// TODO: pass the mode into the module
ftp_pasv($this->conn_id, true);
unset($this->listing_cache);
$this->listing_cache = array();
} else {
$this->updateState(PR_FTP_STATE_ERROR);
}
} else {
$this->updateState(PR_FTP_STATE_DISCONNECTED);
$this->updateStatus(PR_FTP_STATUS_NOT_READY);
}
} else {
$this->updateState(PR_FTP_STATE_DISCONNECTED);
$this->updateStatus(PR_FTP_STATUS_NOT_READY);
}
}
示例2: pwd
function pwd()
{
$this->login();
$dir = ftp_pwd($this->link_id);
$this->dir = $dir;
return $dir;
}
示例3: __call
/**
* Magic method (do not call directly).
* @param string method name
* @param array arguments
* @return mixed
* @throws MemberAccessException
* @throws FtpException
*/
public function __call($name, $args)
{
$name = strtolower($name);
$silent = strncmp($name, 'try', 3) === 0;
$func = $silent ? substr($name, 3) : $name;
static $aliases = array('sslconnect' => 'ssl_connect', 'getoption' => 'get_option', 'setoption' => 'set_option', 'nbcontinue' => 'nb_continue', 'nbfget' => 'nb_fget', 'nbfput' => 'nb_fput', 'nbget' => 'nb_get', 'nbput' => 'nb_put');
$func = 'ftp_' . (isset($aliases[$func]) ? $aliases[$func] : $func);
if (!function_exists($func)) {
return parent::__call($name, $args);
}
Tools::tryError();
if ($func === 'ftp_connect' || $func === 'ftp_ssl_connect') {
$this->state = array($name => $args);
$this->resource = call_user_func_array($func, $args);
$res = NULL;
} elseif (!is_resource($this->resource)) {
Tools::catchError($msg);
throw new FtpException("Not connected to FTP server. Call connect() or ssl_connect() first.");
} else {
if ($func === 'ftp_login' || $func === 'ftp_pasv') {
$this->state[$name] = $args;
}
array_unshift($args, $this->resource);
$res = call_user_func_array($func, $args);
if ($func === 'ftp_chdir' || $func === 'ftp_cdup') {
$this->state['chdir'] = array(ftp_pwd($this->resource));
}
}
if (Tools::catchError($msg) && !$silent) {
throw new FtpException($msg);
}
return $res;
}
示例4: exists
public function exists($path)
{
if (!$this->stream) {
$this->connectAndLogin();
}
$pwd = ftp_pwd($this->stream);
// try to change directory to see if it is an existing directory
$result = @ftp_chdir($this->stream, $path);
if (true === $result) {
ftp_chdir($this->stream, $pwd);
// change back to the original directory
return true;
} else {
// list the parent directory and check if the file exists
$parent = dirname($path);
$options = '-a';
// list hidden
$result = ftp_rawlist($this->stream, $options . ' ' . $parent);
if (false !== $result) {
foreach ($result as $line) {
if (false !== ($pos = strrpos($line, basename($path)))) {
return true;
}
}
}
}
return false;
}
示例5: getListing
public function getListing()
{
$dir = $this->directory;
// Parse directory to parts
$parsed_dir = trim($dir, '/');
$this->parts = empty($parsed_dir) ? array() : explode('/', $parsed_dir);
// Find the path to the parent directory
if (!empty($parts)) {
$copy_of_parts = $parts;
array_pop($copy_of_parts);
if (!empty($copy_of_parts)) {
$this->parent_directory = '/' . implode('/', $copy_of_parts);
} else {
$this->parent_directory = '/';
}
} else {
$this->parent_directory = '';
}
// Connect to the server
if ($this->ssl) {
$con = @ftp_ssl_connect($this->host, $this->port);
} else {
$con = @ftp_connect($this->host, $this->port);
}
if ($con === false) {
$this->setError(JText::_('FTPBROWSER_ERROR_HOSTNAME'));
return false;
}
// Login
$result = @ftp_login($con, $this->username, $this->password);
if ($result === false) {
$this->setError(JText::_('FTPBROWSER_ERROR_USERPASS'));
return false;
}
// Set the passive mode -- don't care if it fails, though!
@ftp_pasv($con, $this->passive);
// Try to chdir to the specified directory
if (!empty($dir)) {
$result = @ftp_chdir($con, $dir);
if ($result === false) {
$this->setError(JText::_('FTPBROWSER_ERROR_NOACCESS'));
return false;
}
} else {
$this->directory = @ftp_pwd($con);
$parsed_dir = trim($this->directory, '/');
$this->parts = empty($parsed_dir) ? array() : explode('/', $parsed_dir);
$this->parent_directory = $this->directory;
}
// Get a raw directory listing (hoping it's a UNIX server!)
$list = @ftp_rawlist($con, '.');
ftp_close($con);
if ($list === false) {
$this->setError(JText::_('FTPBROWSER_ERROR_UNSUPPORTED'));
return false;
}
// Parse the raw listing into an array
$folders = $this->parse_rawlist($list);
return $folders;
}
示例6: store
/**
* 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;
}
}
示例7: 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);
}
示例8: getFiles
/**
* Récupère la liste des fichiers en fonction du pointeur
*
* @require class FileFolder
*
* @param string $path -> Le chemin du répertoire à lister
* @param array $hidden_folders -> Les dossiers à masquer : array('dossier1', 'dossier2);
* @param array $hidden_files -> Les fichiers ou extension à masquer : array('Thumbs.db', 'index.php', 'exe');
* @return array ['path'], ['folders'], ['files']
*/
public static function getFiles($path = null, $hidden_folders = array(), $hidden_files = array())
{
// Si la class FileFolder est instanciée
if (class_exists('FileFolder')) {
// Initialisation
$out = array('path' => null, 'folders' => null, 'files' => null);
$link = self::connection();
// Si la connexion à réussie
if (is_resource($link)) {
// Si aucun chemin n'est spécifié, on récupère le dossier courant
if ($path == null) {
$path = @ftp_pwd($link);
}
$out['path'] = $path;
// Liste des fichiers
$files = ftp_rawlist($link, $path);
if (count($files) > 0) {
foreach ($files as $file) {
// Parse
$data = preg_split("#[\\s]+#", $file, 9);
// Si c'est un dossier
if ($data[0][0] === 'd') {
// Si le dossier n'est pas parmi les dossiers masqués
if ($data[8] != '.' && $data[8] != '..' && !in_array($data[8], $hidden_folders)) {
$out['folders'][$data[8]]['items'] = $data[1];
$out['folders'][$data[8]]['mtime'] = date('d/m/Y H:i:s', strtotime($data[5] . ' ' . $data[6] . ' ' . $data[7]));
$out['folders'][$data[8]]['chmod'] = $data[0];
$out['folders'][$data[8]]['user'] = $data[2];
$out['folders'][$data[8]]['group'] = $data[3];
}
} else {
// Si c'est un fichier different des fichiers masqués
if (!in_array($data[8], $hidden_files)) {
// Si le fichier est différent d'une extension masquée
if (!in_array(FileFolder::getFilenameExtension($data[8]), $hidden_files)) {
$out['files'][$data[8]]['size'] = FileFolder::formatSize($data[4]);
$out['files'][$data[8]]['ext'] = FileFolder::getFilenameExtension($data[8]);
$out['files'][$data[8]]['type'] = FileFolder::getFileType($data[8]);
$out['files'][$data[8]]['mtime'] = date('d/m/Y H:i:s', strtotime($data[5] . ' ' . $data[6] . ' ' . $data[7]));
$out['files'][$data[8]]['chmod'] = $data[0];
$out['files'][$data[8]]['user'] = $data[2];
$out['files'][$data[8]]['group'] = $data[3];
}
}
}
}
}
// Déconnexion
self::disconnection($link);
// Retour
return $out;
} else {
return $link;
}
} else {
return 'class FileFolder no exists';
}
}
示例9: CheckDir
public static function CheckDir($dirname, $conn)
{
$origin = ftp_pwd($conn);
if (@ftp_chdir($conn, $dirname)) {
ftp_chdir($conn, $origin);
return ftp_nlist($conn, $dirname);
}
return false;
}
示例10: pwd
/**
* Get current directory
*/
public function pwd()
{
Logger::log('pwd ');
$result = ftp_pwd($this->connectionId);
if (empty($result)) {
Logger::log('pwd command return false');
}
return $result;
}
示例11: ftp_is_dir
function ftp_is_dir($ftp, $dir)
{
$pushd = ftp_pwd($ftp);
if ($pushd !== false && @ftp_chdir($ftp, $dir)) {
ftp_chdir($ftp, $pushd);
return true;
}
return false;
}
示例12: isDirectory
/**
* Vérifie si le chemin pointe sur un fichier sur le serveur.
*
* @param string $dirname
* @return bool
*/
public function isDirectory($dirname)
{
$tmp = ftp_pwd($this->ftp);
$r = false;
if (ftp_chdir($this->ftp, $dirname)) {
$r = true;
ftp_chdir($this->ftp, $tmp);
}
return $r;
}
示例13: ftp_is_dir
function ftp_is_dir($ftp_stream, $dir)
{
$original_directory = ftp_pwd($ftp_stream);
if (@ftp_chdir($ftp_stream, $dir)) {
ftp_chdir($ftp_stream, $original_directory);
return true;
} else {
return false;
}
}
示例14: is_dir
public function is_dir($strPath)
{
$origin = @ftp_pwd($this->objFTP);
if (@ftp_chdir($this->objFTP, $strPath)) {
ftp_chdir($this->objFTP, $origin);
return true;
} else {
return false;
}
}
示例15: ftp_is_dir
public function ftp_is_dir($dir)
{
$orig_rid = ftp_pwd($this->ftp_conn);
if (@ftp_chdir($this->ftp_conn, $dir)) {
ftp_chdir($this->ftp_conn, $orig_rid);
return true;
} else {
return false;
}
}